Merge branch 'saas' into saas-media-refactor
Conflicts: airtime_mvc/application/modules/rest/controllers/MediaController.php
This commit is contained in:
commit
f1a311dad6
4 changed files with 62 additions and 59 deletions
|
@ -192,6 +192,8 @@ class CcFiles extends BaseCcFiles {
|
||||||
$fileArray = self::removeBlacklistedFields($fileArray);
|
$fileArray = self::removeBlacklistedFields($fileArray);
|
||||||
$fileArray = self::stripTimeStampFromYearTag($fileArray);
|
$fileArray = self::stripTimeStampFromYearTag($fileArray);
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
self::validateFileArray($fileArray);
|
self::validateFileArray($fileArray);
|
||||||
if ($file && isset($fileArray["resource_id"])) {
|
if ($file && isset($fileArray["resource_id"])) {
|
||||||
|
|
||||||
|
@ -201,10 +203,8 @@ class CcFiles extends BaseCcFiles {
|
||||||
$file->setDbFilepath($fileArray["filename"]);
|
$file->setDbFilepath($fileArray["filename"]);
|
||||||
|
|
||||||
$fileSizeBytes = $fileArray["filesize"];
|
$fileSizeBytes = $fileArray["filesize"];
|
||||||
if (!isset($fileSizeBytes) || $fileSizeBytes === false)
|
if (!isset($fileSizeBytes) || $fileSizeBytes === false) {
|
||||||
{
|
throw new FileNotFoundException("Invalid filesize for $fileId");
|
||||||
$file->setDbImportStatus(self::IMPORT_STATUS_FAILED)->save();
|
|
||||||
throw new FileNotFoundException();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$cloudFile = new CloudFile();
|
$cloudFile = new CloudFile();
|
||||||
|
@ -231,10 +231,8 @@ class CcFiles extends BaseCcFiles {
|
||||||
//as a foreign key to cc_music_dirs.
|
//as a foreign key to cc_music_dirs.
|
||||||
if (isset($fileArray["full_path"])) {
|
if (isset($fileArray["full_path"])) {
|
||||||
$fileSizeBytes = filesize($fileArray["full_path"]);
|
$fileSizeBytes = filesize($fileArray["full_path"]);
|
||||||
if (!isset($fileSizeBytes) || $fileSizeBytes === false)
|
if (!isset($fileSizeBytes) || $fileSizeBytes === false) {
|
||||||
{
|
throw new FileNotFoundException("Invalid filesize for $fileId");
|
||||||
$file->setDbImportStatus(self::IMPORT_STATUS_FAILED)->save();
|
|
||||||
throw new FileNotFoundException();
|
|
||||||
}
|
}
|
||||||
Application_Model_Preference::updateDiskUsage($fileSizeBytes);
|
Application_Model_Preference::updateDiskUsage($fileSizeBytes);
|
||||||
|
|
||||||
|
@ -242,8 +240,7 @@ class CcFiles extends BaseCcFiles {
|
||||||
$storDir = Application_Model_MusicDir::getStorDir()->getDirectory();
|
$storDir = Application_Model_MusicDir::getStorDir()->getDirectory();
|
||||||
$pos = strpos($fullPath, $storDir);
|
$pos = strpos($fullPath, $storDir);
|
||||||
|
|
||||||
if ($pos !== FALSE)
|
if ($pos !== FALSE) {
|
||||||
{
|
|
||||||
assert($pos == 0); //Path must start with the stor directory path
|
assert($pos == 0); //Path must start with the stor directory path
|
||||||
|
|
||||||
$filePathRelativeToStor = substr($fullPath, strlen($storDir));
|
$filePathRelativeToStor = substr($fullPath, strlen($storDir));
|
||||||
|
@ -255,12 +252,17 @@ class CcFiles extends BaseCcFiles {
|
||||||
$file->setDbMtime($now);
|
$file->setDbMtime($now);
|
||||||
$file->save();
|
$file->save();
|
||||||
|
|
||||||
/* $this->removeEmptySubFolders(
|
|
||||||
isset($_SERVER['AIRTIME_BASE']) ? $_SERVER['AIRTIME_BASE']."/srv/airtime/stor/organize/" : "/srv/airtime/stor/organize/"); */
|
|
||||||
} else {
|
} else {
|
||||||
$file->setDbImportStatus(self::IMPORT_STATUS_FAILED)->save();
|
|
||||||
throw new FileNotFoundException();
|
throw new FileNotFoundException();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
catch (FileNotFoundException $e)
|
||||||
|
{
|
||||||
|
$file->setDbImportStatus(self::IMPORT_STATUS_FAILED);
|
||||||
|
$file->setDbHidden(true);
|
||||||
|
$file->save();
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
|
||||||
return CcFiles::sanitizeResponse($file);
|
return CcFiles::sanitizeResponse($file);
|
||||||
}
|
}
|
||||||
|
@ -409,7 +411,7 @@ class CcFiles extends BaseCcFiles {
|
||||||
{
|
{
|
||||||
$music_dir = Application_Model_MusicDir::getDirByPK($this->getDbDirectory());
|
$music_dir = Application_Model_MusicDir::getDirByPK($this->getDbDirectory());
|
||||||
if (!$music_dir) {
|
if (!$music_dir) {
|
||||||
throw new Exception("Invalid music_dir for file in database.");
|
throw new Exception("Invalid music_dir for file " . $this->getDbId() . " in database.");
|
||||||
}
|
}
|
||||||
$directory = $music_dir->getDirectory();
|
$directory = $music_dir->getDirectory();
|
||||||
$filepath = $this->getDbFilepath();
|
$filepath = $this->getDbFilepath();
|
||||||
|
|
|
@ -119,6 +119,7 @@ class Rest_MediaController extends Zend_Rest_Controller
|
||||||
try {
|
try {
|
||||||
$requestData = json_decode($this->getRequest()->getRawBody(), true);
|
$requestData = json_decode($this->getRequest()->getRawBody(), true);
|
||||||
$sanitizedFile = CcFiles::updateFromArray($id, $requestData);
|
$sanitizedFile = CcFiles::updateFromArray($id, $requestData);
|
||||||
|
|
||||||
$this->getResponse()
|
$this->getResponse()
|
||||||
->setHttpResponseCode(201)
|
->setHttpResponseCode(201)
|
||||||
->appendBody(json_encode($sanitizedFile));
|
->appendBody(json_encode($sanitizedFile));
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<?php if($this->trial_remain != '' && $this->trial_remain != "Trial expired."){?>
|
<?php if($this->is_trial && $this->trial_remain != '' && $this->trial_remain != "Trial expired."){?>
|
||||||
<div class="trial-box">
|
<div class="trial-box">
|
||||||
<p><?php echo _("Your trial expires in") ?></p>
|
<p><?php echo _("Your trial expires in") ?></p>
|
||||||
<div class="trial-box-calendar">
|
<div class="trial-box-calendar">
|
||||||
|
|
|
@ -167,7 +167,7 @@ class PypoFile(Thread):
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
logging.debug("Failed to open config file at %s: %s" % (config_path, e.strerror))
|
logging.debug("Failed to open config file at %s: %s" % (config_path, e.strerror))
|
||||||
sys.exit()
|
sys.exit()
|
||||||
except Exception:
|
except Exception as e:
|
||||||
logging.debug(e.strerror)
|
logging.debug(e.strerror)
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue