From bfd6ef72b18f19b82c0ff94ed6d3800420c90f2a Mon Sep 17 00:00:00 2001 From: Albert Santoni Date: Thu, 26 Feb 2015 11:29:08 -0500 Subject: [PATCH] Fixed download URLs for non-cloud files --- airtime_mvc/application/controllers/LibraryController.php | 2 +- airtime_mvc/application/models/airtime/CcFiles.php | 3 ++- airtime_mvc/application/services/MediaService.php | 8 -------- 3 files changed, 3 insertions(+), 10 deletions(-) diff --git a/airtime_mvc/application/controllers/LibraryController.php b/airtime_mvc/application/controllers/LibraryController.php index 3e7d33cd7..8c635baa6 100644 --- a/airtime_mvc/application/controllers/LibraryController.php +++ b/airtime_mvc/application/controllers/LibraryController.php @@ -217,7 +217,7 @@ class LibraryController extends Zend_Controller_Action // and not the cloud_file id (if applicable) for track download. // Our application logic (StoredFile.php) will determine if the track // is a cloud_file and handle it appropriately. - $url = $baseUrl."api/get-media/file/".$id.".".$file->getFileExtension().'/download/true'; + $url = $baseUrl."api/get-media/file/$id/download/true"; $menu["download"] = array("name" => _("Download"), "icon" => "download", "url" => $url); } elseif ($type === "playlist" || $type === "block") { if ($type === 'playlist') { diff --git a/airtime_mvc/application/models/airtime/CcFiles.php b/airtime_mvc/application/models/airtime/CcFiles.php index 079b47556..148eb37c0 100644 --- a/airtime_mvc/application/models/airtime/CcFiles.php +++ b/airtime_mvc/application/models/airtime/CcFiles.php @@ -388,7 +388,8 @@ class CcFiles extends BaseCcFiles { public function getFilename() { $info = pathinfo($this->getAbsoluteFilePath()); - return $info['filename']; + //filename doesn't contain the extension because PHP is awful + return $info['filename'].".".$info['extension']; } /** diff --git a/airtime_mvc/application/services/MediaService.php b/airtime_mvc/application/services/MediaService.php index eb0ad339a..ee4238e8d 100644 --- a/airtime_mvc/application/services/MediaService.php +++ b/airtime_mvc/application/services/MediaService.php @@ -56,19 +56,11 @@ class Application_Service_MediaService throw new FileNotFoundException(); } $filepath = $media->getFilePath(); - // Make sure we don't have some wrong result beecause of caching - clearstatcache(); - $media = Application_Model_StoredFile::RecallById($fileId); - if ($media == null) { - throw new FileNotFoundException(); - } - // Make sure we don't have some wrong result beecause of caching clearstatcache(); if ($media->getPropelOrm()->isValidPhysicalFile()) { $filename = $media->getPropelOrm()->getFilename(); - //Download user left clicks a track and selects Download. if (!$inline) { //We are using Content-Disposition to specify