From 4ffc2537c89765533c7489917383b8dc4dcf97fd Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Sat, 15 Oct 2022 17:27:03 +0530 Subject: [PATCH] PD purge : ps --- .../controllers/Data_Dump_Controller.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/api/application/controllers/Data_Dump_Controller.php b/api/application/controllers/Data_Dump_Controller.php index b8fda6b8..5d6c30f8 100644 --- a/api/application/controllers/Data_Dump_Controller.php +++ b/api/application/controllers/Data_Dump_Controller.php @@ -945,15 +945,16 @@ class Data_Dump_Controller extends REST_Controller for ($m = 0; $m < count($docs_dtls); $m++) { log_message('ERROR', "Document " . $docs_dtls[$m]['pd_document_name']); $docname = $docs_dtls[$m]['pd_document_name']; - $destination_path = $this->external_path . "/pd_reports/" . $pdid . "/" . $docname; - if (file_exists($destination_path)) { - unlink($destination_path); - }else{ - mkdir($destination_path, 0777); + $destination_path = $this->external_path . "/pd_reports/" . $pdid; + $files = glob($destination_path.'/*'); + + foreach($files as $file) { + if(is_file($file)) + // Delete the given file + unlink($file); } - $bucketname = LENDER_BUCKET_NAME_PREFIX . $pdlenid; - $key = 'pd' . $pdid . '/' . $docname; + $key = 'pd' . $pdid . '/*'; $s3result = $this->aws_s3->deleteSingleObjFromBucket($bucketname, $key); if (is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200) { log_message('ERROR', "s3result " . $s3result['@metadata']['statusCode']);