diff --git a/airtime_mvc/application/modules/rest/controllers/MediaController.php b/airtime_mvc/application/modules/rest/controllers/MediaController.php index b6260a483..d9416548c 100644 --- a/airtime_mvc/application/modules/rest/controllers/MediaController.php +++ b/airtime_mvc/application/modules/rest/controllers/MediaController.php @@ -1,8 +1,13 @@ findPk($id); + // Since we check for this value when deleting files, set it first + $file->setDbDirectory(self::MUSIC_DIRS_STOR_PK); $requestData = json_decode($this->getRequest()->getRawBody(), true); $whiteList = $this->removeBlacklistedFieldsFromRequestData($requestData); @@ -232,7 +239,7 @@ class Rest_MediaController extends Zend_Rest_Controller $fileSizeBytes = filesize($requestData["full_path"]); if ($fileSizeBytes === false) { - $file->setDbImportStatus(2)->save(); + $file->setDbImportStatus(self::IMPORT_STATUS_FAILED)->save(); $this->fileNotFoundResponse(); return; } @@ -248,7 +255,6 @@ class Rest_MediaController extends Zend_Rest_Controller $filePathRelativeToStor = substr($fullPath, strlen($storDir)); $file->setDbFilepath($filePathRelativeToStor); - $file->setDbDirectory(1); //1 corresponds to the default stor/imported directory. } } @@ -263,7 +269,7 @@ class Rest_MediaController extends Zend_Rest_Controller ->setHttpResponseCode(200) ->appendBody(json_encode(CcFiles::sanitizeResponse($file))); } else { - $file->setDbImportStatus(2)->save(); + $file->setDbImportStatus(self::IMPORT_STATUS_FAILED)->save(); $this->fileNotFoundResponse(); } } @@ -274,6 +280,7 @@ class Rest_MediaController extends Zend_Rest_Controller { return; } + $id = $this->getId(); if (!$id) {