From ba941f0c54e1af6ff1960e33fc35f24e02b32417 Mon Sep 17 00:00:00 2001 From: louis Date: Thu, 13 Aug 2015 12:42:59 +0200 Subject: [PATCH] Dev: remove tmp files of update process --- application/controllers/admin/update.php | 3 +++ application/models/UpdateForm.php | 22 ++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/application/controllers/admin/update.php b/application/controllers/admin/update.php index 11c77930a49..466524ef6da 100755 --- a/application/controllers/admin/update.php +++ b/application/controllers/admin/update.php @@ -270,6 +270,9 @@ function step4() // Should never bug (version.php is checked before)) $updateModel->updateVersion($destinationBuild); $updateModel->destroyGlobalSettings(); + $updateModel->removeTmpFile('update.zip'); + $updateModel->removeTmpFile('comfort_updater_cookie.txt'); + // TODO : aData should contains information about each step return $this->controller->renderPartial('update/updater/steps/_final', array(), false, true); } diff --git a/application/models/UpdateForm.php b/application/models/UpdateForm.php index c15633e0452..5357c194704 100644 --- a/application/models/UpdateForm.php +++ b/application/models/UpdateForm.php @@ -339,6 +339,28 @@ public function removeDeletedFiles($updateinfos) return (object) $return; } + /** + * Delete a tmp file + * @param string the name of the file to delete in tmp/ directory + * @return obj + */ + public function removeTmpFile($sTmpFile = 'update.zip') + { + $sTmpFilePath = $this->tempdir.DIRECTORY_SEPARATOR.$sTmpFile; + if ( file_exists( $sTmpFilePath ) ) + { + if( ! @unlink( $sTmpFilePath ) ) + { + $return = array('result'=>FALSE, 'error'=>'cant_remove_update_file', 'message'=>'file : '.$sTmpFilePath); + return (object) $return; + } + } + + $return = array('result' => TRUE); + return (object) $return; + } + + /** * Update the version file to the destination build version * @param INT $destinationBuild the id of the new version