From 11a31375df4ccf0313e1f07ca8287b1424840770 Mon Sep 17 00:00:00 2001 From: Albert Santoni Date: Tue, 18 Nov 2014 17:41:44 -0500 Subject: [PATCH] Slightly more robust fix for the last issue --- airtime_mvc/application/models/StoredFile.php | 17 ++++++++--------- .../rest/controllers/MediaController.php | 3 +-- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/airtime_mvc/application/models/StoredFile.php b/airtime_mvc/application/models/StoredFile.php index 8c5910182..ab5ada697 100644 --- a/airtime_mvc/application/models/StoredFile.php +++ b/airtime_mvc/application/models/StoredFile.php @@ -355,13 +355,8 @@ SQL; { $exists = false; try { - //Explicitly check filepath because if it's blank, getFilePath() can - //still return a directory that exists. - if (!$this->_file->getDbFilepath()) { - $exists = false; - } else { - $exists = file_exists($this->getFilePath()); - } + $filePath = $this->getFilePath(); + $exists = (file_exists($this->getFilePath()) && !is_dir($filePath)); } catch (Exception $e) { return false; } @@ -504,11 +499,15 @@ SQL; $music_dir = Application_Model_MusicDir::getDirByPK($this-> _file->getDbDirectory()); if (!$music_dir) { - throw new Exception("Invalid music_dir for file in database."); + throw new Exception(_("Invalid music_dir for file in database.")); } + $directory = $music_dir->getDirectory(); $filepath = $this->_file->getDbFilepath(); - + if (!$filepath) { + throw new Exception(sprintf(_("Blank file path for file %s (id: %s) in database."), $this->_file->getDbTrackTitle(), $this->getId())); + } + return Application_Common_OsPath::join($directory, $filepath); } diff --git a/airtime_mvc/application/modules/rest/controllers/MediaController.php b/airtime_mvc/application/modules/rest/controllers/MediaController.php index 243eeeb50..7cc5f370a 100644 --- a/airtime_mvc/application/modules/rest/controllers/MediaController.php +++ b/airtime_mvc/application/modules/rest/controllers/MediaController.php @@ -276,8 +276,7 @@ class Rest_MediaController extends Zend_Rest_Controller { return; } - - + $id = $this->getId(); if (!$id) { return;