Skip to content

Commit

Permalink
Add a method to clean up unused files
Browse files Browse the repository at this point in the history
  • Loading branch information
mah0001 committed Dec 14, 2023
1 parent 7944623 commit 56eab71
Showing 1 changed file with 37 additions and 1 deletion.
38 changes: 37 additions & 1 deletion application/controllers/api/Datafiles.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,9 @@ function delete_post($sid=null,$file_id=null)
try{
$sid=$this->get_sid($sid);
$this->editor_acl->user_has_project_access($sid,$permission='edit');
$this->Editor_model->data_file_delete($sid,$file_id);
$this->Editor_datafile_model->cleanup($sid,$file_id);
$this->Editor_datafile_model->delete_physical_file($sid,$file_id);
$this->Editor_datafile_model->delete($sid,$file_id);

$response=array(
'status'=>'success'
Expand Down Expand Up @@ -386,4 +388,38 @@ function generate_fid_get($sid=null)
}



/**
*
* Clean up temporary data files
*
* - removes original data files [keep only the csv version]
*
*/
function cleanup_post($sid=null, $file_id=null)
{
try{
$sid=$this->get_sid($sid);
$user_id=$this->get_api_user_id();

$this->editor_acl->user_has_project_access($sid,$permission='edit');
$result=$this->Editor_datafile_model->cleanup($sid, $file_id);

$response=array(
'status'=>'success',
'files_removed'=>$result
);

$this->set_response($response, REST_Controller::HTTP_OK);
}
catch(Exception $e){
$error_output=array(
'status'=>'failed',
'message'=>$e->getMessage()
);
$this->set_response($error_output, REST_Controller::HTTP_BAD_REQUEST);
}
}


}

0 comments on commit 56eab71

Please sign in to comment.