cc-1799 Human Readable File System
refactoring media monitor, separate process for file event processing.
This commit is contained in:
parent
d642a48e8c
commit
65e647263f
10 changed files with 616 additions and 662 deletions
|
@ -54,7 +54,7 @@ class ApiController extends Zend_Controller_Action
|
|||
* Allows remote client to download requested media file.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
*
|
||||
*/
|
||||
public function getMediaAction()
|
||||
{
|
||||
|
@ -374,39 +374,7 @@ class ApiController extends Zend_Controller_Action
|
|||
exit;
|
||||
}
|
||||
|
||||
$plupload_dir = ini_get("upload_tmp_dir") . DIRECTORY_SEPARATOR . "plupload";
|
||||
|
||||
//need to make sure plupload dir exists so we can watch it.
|
||||
if(!file_exists($plupload_dir)) {
|
||||
@mkdir($plupload_dir, 0755);
|
||||
}
|
||||
|
||||
$this->view->stor = $CC_CONFIG['storageDir'];
|
||||
$this->view->plupload = $plupload_dir;
|
||||
}
|
||||
|
||||
public function mediaItemStatusAction() {
|
||||
global $CC_CONFIG;
|
||||
|
||||
$api_key = $this->_getParam('api_key');
|
||||
if (!in_array($api_key, $CC_CONFIG["apiKey"]))
|
||||
{
|
||||
header('HTTP/1.0 401 Unauthorized');
|
||||
print 'You are not allowed to access this resource.';
|
||||
exit;
|
||||
}
|
||||
|
||||
$md5 = $this->_getParam('md5');
|
||||
$file = StoredFile::RecallByMd5($md5);
|
||||
|
||||
//New file added to Airtime
|
||||
if (is_null($file)) {
|
||||
$this->view->airtime_status = 0;
|
||||
}
|
||||
else {
|
||||
$this->view->airtime_status = 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function reloadMetadataAction() {
|
||||
|
@ -471,7 +439,7 @@ class ApiController extends Zend_Controller_Action
|
|||
$filepath = $md['MDATA_KEY_FILEPATH'];
|
||||
$filepath = str_replace("\\", "", $filepath);
|
||||
$file->setFilePath($filepath);
|
||||
$file->setMetadata($md);
|
||||
//$file->setMetadata($md);
|
||||
}
|
||||
}
|
||||
else if ($mode == "delete") {
|
||||
|
|
|
@ -27,10 +27,6 @@ class PluploadController extends Zend_Controller_Action
|
|||
$upload_dir = ini_get("upload_tmp_dir") . DIRECTORY_SEPARATOR . "plupload";
|
||||
$res = StoredFile::uploadFile($upload_dir);
|
||||
|
||||
if (isset($res)) {
|
||||
die('{"jsonrpc" : "2.0", "id" : '.$file->getMessage().' }');
|
||||
}
|
||||
|
||||
die('{"jsonrpc" : "2.0"}');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -95,9 +95,9 @@ class StoredFile {
|
|||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$sql = "SELECT count(*) as cnt FROM ".$CC_CONFIG["filesTable"]." WHERE state='ready'";
|
||||
return $CC_DBC->GetOne($sql);
|
||||
return $CC_DBC->GetOne($sql);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set multiple metadata values using database columns as indexes.
|
||||
*
|
||||
|
@ -717,7 +717,7 @@ class StoredFile {
|
|||
$fileName = isset($_REQUEST["name"]) ? $_REQUEST["name"] : '';
|
||||
|
||||
// Clean the fileName for security reasons
|
||||
//$fileName = preg_replace('/[^\w\._]+/', '', $fileName);
|
||||
$fileName = preg_replace('/[^\w\._]+/', '', $fileName);
|
||||
|
||||
// Create target dir
|
||||
if (!file_exists($p_targetDir))
|
||||
|
@ -791,34 +791,19 @@ class StoredFile {
|
|||
die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": ' . $duplicate->getMessage() .'}}');
|
||||
}
|
||||
else {
|
||||
if (file_exists($duplicate->getRealFilePath())) {
|
||||
if (file_exists($duplicate->getFilePath())) {
|
||||
$duplicateName = $duplicate->getMetadataValue(UI_MDATA_KEY_TITLE);
|
||||
die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": "An identical audioclip named ' . $duplicateName . ' already exists in the storage server."}}');
|
||||
}
|
||||
else {
|
||||
$res = $duplicate->replaceFile($audio_file);
|
||||
if (PEAR::isError($res)) {
|
||||
die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": ' . $duplicate->getMessage() .'}}');
|
||||
}
|
||||
return $duplicate;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
$storDir = MusicDir::getStorDir();
|
||||
$stor = $storDir->getDirectory();
|
||||
$storDir = MusicDir::getStorDir();
|
||||
$stor = $storDir->getDirectory();
|
||||
|
||||
$audio_stor = $stor . DIRECTORY_SEPARATOR . $fileName;
|
||||
$audio_stor = $stor . DIRECTORY_SEPARATOR . $fileName;
|
||||
|
||||
$md = array();
|
||||
$md['MDATA_KEY_MD5'] = $md5;
|
||||
$md['MDATA_KEY_FILEPATH'] = $audio_stor;
|
||||
$md['MDATA_KEY_TITLE'] = $fileName;
|
||||
|
||||
StoredFile::Insert($md);
|
||||
$r = @rename($audio_file, $audio_stor);
|
||||
}
|
||||
$r = @copy($audio_file, $audio_stor);
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue