Fixed download URLs for non-cloud files

This commit is contained in:
Albert Santoni 2015-02-26 11:29:08 -05:00
parent 3885abbdb8
commit bfd6ef72b1
3 changed files with 3 additions and 10 deletions

View File

@ -217,7 +217,7 @@ class LibraryController extends Zend_Controller_Action
// and not the cloud_file id (if applicable) for track download. // and not the cloud_file id (if applicable) for track download.
// Our application logic (StoredFile.php) will determine if the track // Our application logic (StoredFile.php) will determine if the track
// is a cloud_file and handle it appropriately. // 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); $menu["download"] = array("name" => _("Download"), "icon" => "download", "url" => $url);
} elseif ($type === "playlist" || $type === "block") { } elseif ($type === "playlist" || $type === "block") {
if ($type === 'playlist') { if ($type === 'playlist') {

View File

@ -388,7 +388,8 @@ class CcFiles extends BaseCcFiles {
public function getFilename() public function getFilename()
{ {
$info = pathinfo($this->getAbsoluteFilePath()); $info = pathinfo($this->getAbsoluteFilePath());
return $info['filename']; //filename doesn't contain the extension because PHP is awful
return $info['filename'].".".$info['extension'];
} }
/** /**

View File

@ -56,19 +56,11 @@ class Application_Service_MediaService
throw new FileNotFoundException(); throw new FileNotFoundException();
} }
$filepath = $media->getFilePath(); $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 // Make sure we don't have some wrong result beecause of caching
clearstatcache(); clearstatcache();
if ($media->getPropelOrm()->isValidPhysicalFile()) { if ($media->getPropelOrm()->isValidPhysicalFile()) {
$filename = $media->getPropelOrm()->getFilename(); $filename = $media->getPropelOrm()->getFilename();
//Download user left clicks a track and selects Download. //Download user left clicks a track and selects Download.
if (!$inline) { if (!$inline) {
//We are using Content-Disposition to specify //We are using Content-Disposition to specify