From 1cf3a5ca3a995452b84b37d7590e6dbdeafa419f Mon Sep 17 00:00:00 2001 From: Duncan Sommerville Date: Wed, 17 Sep 2014 19:53:23 -0400 Subject: [PATCH] Fixed always deleting file tree for show image even if directory was non-existant --- .../modules/rest/controllers/ShowController.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/airtime_mvc/application/modules/rest/controllers/ShowController.php b/airtime_mvc/application/modules/rest/controllers/ShowController.php index 537ff49c7..ece72b369 100644 --- a/airtime_mvc/application/modules/rest/controllers/ShowController.php +++ b/airtime_mvc/application/modules/rest/controllers/ShowController.php @@ -190,9 +190,15 @@ class Rest_ShowController extends Zend_Rest_Controller Logging::info("Deleting images from " . $importedStorageDirectory); // to be safe in case image uploading functionality is extended later - return Rest_ShowController::delTree($importedStorageDirectory); + if (!file_exists($importedStorageDirectory)) { + Logging::info("No uploaded images for show with id " . $showId); + return true; + } else { + return Rest_ShowController::delTree($importedStorageDirectory); + } } + // from a comment @ http://php.net/manual/en/function.rmdir.php private static function delTree($dir) { $files = array_diff(scandir($dir), array('.','..')); foreach ($files as $file) {