CC-1799 Put Airtime Storage into a Human Readable File Naming Convention

selecting a mode to prevent some cases where a duplicate could be entered for only 1 file.
This commit is contained in:
Naomi Aro 2011-06-10 16:43:30 +02:00
parent 79049315c7
commit 71d853567e
7 changed files with 72 additions and 33 deletions

View file

@ -409,18 +409,35 @@ class ApiController extends Zend_Controller_Action
}
$md = $this->_getParam('md');
$filepath = $md['MDATA_KEY_FILEPATH'];
$filepath = str_replace("\\", "", $filepath);
$mode = $this->_getParam('mode');
$file = StoredFile::RecallByFilepath($filepath);
if ($mode == "create") {
$md5 = $md['MDATA_KEY_MD5'];
//New file added to Airtime
if (is_null($file)) {
$file = StoredFile::Insert($md);
$file = StoredFile::RecallByMd5($md5);
if (is_null($file)) {
$file = StoredFile::Insert($md);
}
else {
$this->view->error = "File already exists in Airtime.";
return;
}
}
//Updating a metadata change.
else {
$file->setMetadata($md);
else if ($mode == "modify") {
$filepath = $md['MDATA_KEY_FILEPATH'];
$filepath = str_replace("\\", "", $filepath);
$file = StoredFile::RecallByFilepath($filepath);
//File is not in database anymore.
if (is_null($file)) {
$this->view->error = "File does not exist in Airtime.";
return;
}
//Updating a metadata change.
else {
$file->setMetadata($md);
}
}
$this->view->id = $file->getId();

View file

@ -166,8 +166,8 @@ class LibraryController extends Zend_Controller_Action
$data = $formdata;
$data['filepath'] = $file->getFilePath();
//wait for 1.9.0 release
//RabbitMq::SendFileMetaData($data);
RabbitMq::SendFileMetaData($data);
$this->_helper->redirector('index');
}