Fixed always deleting file tree for show image even if directory was non-existant

This commit is contained in:
Duncan Sommerville 2014-09-17 19:53:23 -04:00
parent 17ea198ea4
commit 1cf3a5ca3a
1 changed files with 7 additions and 1 deletions

View File

@ -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) {