From e1a04299392dbb7ed70bb789142935b0407451c8 Mon Sep 17 00:00:00 2001 From: Albert Santoni Date: Thu, 22 May 2014 19:16:42 -0400 Subject: [PATCH] Handle error case that could cause invalid disk usage reading --- .../modules/rest/controllers/MediaController.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/airtime_mvc/application/modules/rest/controllers/MediaController.php b/airtime_mvc/application/modules/rest/controllers/MediaController.php index 7bbb3bc95..e4f78652f 100644 --- a/airtime_mvc/application/modules/rest/controllers/MediaController.php +++ b/airtime_mvc/application/modules/rest/controllers/MediaController.php @@ -234,7 +234,14 @@ class Rest_MediaController extends Zend_Rest_Controller //our internal schema. Internally, file path is stored relative to a directory, with the directory //as a foreign key to cc_music_dirs. if (isset($requestData["full_path"])) { - Application_Model_Preference::updateDiskUsage(filesize($requestData["full_path"])); + $fileSizeBytes = filesize($requestData["full_path"]); + if ($fileSizeBytes === false) + { + $file->setDbImportStatus(2)->save(); + $this->fileNotFoundResponse(); + return; + } + Application_Model_Preference::updateDiskUsage($fileSizeBytes); $fullPath = $requestData["full_path"]; $storDir = Application_Model_MusicDir::getStorDir()->getDirectory();