Fixed 'clear' button not working when files failed to import
This commit is contained in:
parent
e7e1926896
commit
6460854fda
1 changed files with 11 additions and 4 deletions
|
@ -1,8 +1,13 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|
||||||
class Rest_MediaController extends Zend_Rest_Controller
|
class Rest_MediaController extends Zend_Rest_Controller
|
||||||
{
|
{
|
||||||
|
const MUSIC_DIRS_STOR_PK = 1;
|
||||||
|
|
||||||
|
const IMPORT_STATUS_SUCCESS = 0;
|
||||||
|
const IMPORT_STATUS_PENDING = 1;
|
||||||
|
const IMPORT_STATUS_FAILED = 2;
|
||||||
|
|
||||||
//fields that are not modifiable via our RESTful API
|
//fields that are not modifiable via our RESTful API
|
||||||
private static $blackList = array(
|
private static $blackList = array(
|
||||||
'id',
|
'id',
|
||||||
|
@ -210,6 +215,8 @@ class Rest_MediaController extends Zend_Rest_Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
$file = CcFilesQuery::create()->findPk($id);
|
$file = CcFilesQuery::create()->findPk($id);
|
||||||
|
// Since we check for this value when deleting files, set it first
|
||||||
|
$file->setDbDirectory(self::MUSIC_DIRS_STOR_PK);
|
||||||
|
|
||||||
$requestData = json_decode($this->getRequest()->getRawBody(), true);
|
$requestData = json_decode($this->getRequest()->getRawBody(), true);
|
||||||
$whiteList = $this->removeBlacklistedFieldsFromRequestData($requestData);
|
$whiteList = $this->removeBlacklistedFieldsFromRequestData($requestData);
|
||||||
|
@ -228,7 +235,7 @@ class Rest_MediaController extends Zend_Rest_Controller
|
||||||
$fileSizeBytes = filesize($requestData["full_path"]);
|
$fileSizeBytes = filesize($requestData["full_path"]);
|
||||||
if (!isset($fileSizeBytes) || $fileSizeBytes === false)
|
if (!isset($fileSizeBytes) || $fileSizeBytes === false)
|
||||||
{
|
{
|
||||||
$file->setDbImportStatus(2)->save();
|
$file->setDbImportStatus(self::IMPORT_STATUS_FAILED)->save();
|
||||||
$this->fileNotFoundResponse();
|
$this->fileNotFoundResponse();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -244,7 +251,6 @@ class Rest_MediaController extends Zend_Rest_Controller
|
||||||
|
|
||||||
$filePathRelativeToStor = substr($fullPath, strlen($storDir));
|
$filePathRelativeToStor = substr($fullPath, strlen($storDir));
|
||||||
$file->setDbFilepath($filePathRelativeToStor);
|
$file->setDbFilepath($filePathRelativeToStor);
|
||||||
$file->setDbDirectory(1); //1 corresponds to the default stor/imported directory.
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -259,7 +265,7 @@ class Rest_MediaController extends Zend_Rest_Controller
|
||||||
->setHttpResponseCode(200)
|
->setHttpResponseCode(200)
|
||||||
->appendBody(json_encode(CcFiles::sanitizeResponse($file)));
|
->appendBody(json_encode(CcFiles::sanitizeResponse($file)));
|
||||||
} else {
|
} else {
|
||||||
$file->setDbImportStatus(2)->save();
|
$file->setDbImportStatus(self::IMPORT_STATUS_FAILED)->save();
|
||||||
$this->fileNotFoundResponse();
|
$this->fileNotFoundResponse();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -270,6 +276,7 @@ class Rest_MediaController extends Zend_Rest_Controller
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$id = $this->getId();
|
$id = $this->getId();
|
||||||
if (!$id) {
|
if (!$id) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue