Small code cleanup
This commit is contained in:
parent
7ca6b91cdf
commit
82d7f09382
|
@ -237,33 +237,6 @@ class Rest_MediaController extends Zend_Rest_Controller
|
||||||
return;
|
return;
|
||||||
} else if ($file) {
|
} else if ($file) {
|
||||||
$file->fromArray($whiteList, BasePeer::TYPE_FIELDNAME);
|
$file->fromArray($whiteList, BasePeer::TYPE_FIELDNAME);
|
||||||
|
|
||||||
//Our RESTful API takes "full_path" as a field, which we then split and translate to match
|
|
||||||
//our internal schema. Internally, file path is stored relative to a directory, with the directory
|
|
||||||
//as a foreign key to cc_music_dirs.
|
|
||||||
/*if (isset($requestData["full_path"])) {
|
|
||||||
$fileSizeBytes = filesize($requestData["full_path"]);
|
|
||||||
if ($fileSizeBytes === false)
|
|
||||||
{
|
|
||||||
$file->setDbImportStatus(2)->save();
|
|
||||||
$this->fileNotFoundResponse();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Application_Model_Preference::updateDiskUsage($fileSizeBytes);
|
|
||||||
|
|
||||||
$fullPath = $requestData["full_path"];
|
|
||||||
$storDir = Application_Model_MusicDir::getStorDir()->getDirectory();
|
|
||||||
$pos = strpos($fullPath, $storDir);
|
|
||||||
|
|
||||||
if ($pos !== FALSE)
|
|
||||||
{
|
|
||||||
assert($pos == 0); //Path must start with the stor directory path
|
|
||||||
|
|
||||||
$filePathRelativeToStor = substr($fullPath, strlen($storDir));
|
|
||||||
$file->setDbFilepath($filePathRelativeToStor);
|
|
||||||
$file->setDbDirectory(1); //1 corresponds to the default stor/imported directory.
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
if (isset($requestData["s3_object_name"])) {
|
if (isset($requestData["s3_object_name"])) {
|
||||||
$cloud_cc_music_dir = CcMusicDirsQuery::create()
|
$cloud_cc_music_dir = CcMusicDirsQuery::create()
|
||||||
|
@ -272,17 +245,13 @@ class Rest_MediaController extends Zend_Rest_Controller
|
||||||
$file->setDbDirectory($cloud_cc_music_dir->getId());
|
$file->setDbDirectory($cloud_cc_music_dir->getId());
|
||||||
$file->setDbResourceId($requestData["s3_object_name"]);
|
$file->setDbResourceId($requestData["s3_object_name"]);
|
||||||
|
|
||||||
//Application_Model_Preference::updateDiskUsage($requestData["filesize"]);
|
Application_Model_Preference::updateDiskUsage($requestData["filesize"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$now = new DateTime("now", new DateTimeZone("UTC"));
|
$now = new DateTime("now", new DateTimeZone("UTC"));
|
||||||
$file->setDbMtime($now);
|
$file->setDbMtime($now);
|
||||||
$file->save();
|
$file->save();
|
||||||
|
|
||||||
//get the filesize and update disk_usage
|
|
||||||
$storedFile = Application_Model_StoredFile::RecallById($file->getDbId());
|
|
||||||
Application_Model_Preference::updateDiskUsage($requestData["filesize"]);
|
|
||||||
|
|
||||||
$this->getResponse()
|
$this->getResponse()
|
||||||
->setHttpResponseCode(200)
|
->setHttpResponseCode(200)
|
||||||
->appendBody(json_encode($this->sanitizeResponse($file)));
|
->appendBody(json_encode($this->sanitizeResponse($file)));
|
||||||
|
@ -335,6 +304,9 @@ class Rest_MediaController extends Zend_Rest_Controller
|
||||||
$storedFile = new Application_Model_StoredFile(CcFilesQuery::create()->findPk($id), $con);
|
$storedFile = new Application_Model_StoredFile(CcFilesQuery::create()->findPk($id), $con);
|
||||||
|
|
||||||
$storedFile->doFileDeletionCleanup($requestData["filesize"]);
|
$storedFile->doFileDeletionCleanup($requestData["filesize"]);
|
||||||
|
|
||||||
|
//refresh library table to remove the deleted file from it
|
||||||
|
//$this->view->headScript()->appendScript("oTable.fnStandingRedraw();");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue