From 6460854fdad351a91fe054a321caa7ab54b3a040 Mon Sep 17 00:00:00 2001 From: Duncan Sommerville Date: Mon, 10 Nov 2014 16:07:23 -0500 Subject: [PATCH] Fixed 'clear' button not working when files failed to import --- .../modules/rest/controllers/MediaController.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/airtime_mvc/application/modules/rest/controllers/MediaController.php b/airtime_mvc/application/modules/rest/controllers/MediaController.php index 87af946bb..243eeeb50 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); @@ -228,7 +235,7 @@ class Rest_MediaController extends Zend_Rest_Controller $fileSizeBytes = filesize($requestData["full_path"]); if (!isset($fileSizeBytes) || $fileSizeBytes === false) { - $file->setDbImportStatus(2)->save(); + $file->setDbImportStatus(self::IMPORT_STATUS_FAILED)->save(); $this->fileNotFoundResponse(); return; } @@ -244,7 +251,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. } } @@ -259,7 +265,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(); } } @@ -270,6 +276,7 @@ class Rest_MediaController extends Zend_Rest_Controller { return; } + $id = $this->getId(); if (!$id) {