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