cc-4105: removed naive replaygain again. added micro optimization to Insert into cc_files

This commit is contained in:
Rudi Grinberg 2012-08-08 15:55:58 -04:00
parent 91145a3f16
commit e98eda144a
3 changed files with 15 additions and 21 deletions

View file

@ -456,8 +456,8 @@ class ApiController extends Zend_Controller_Action
$this->view->watched_dirs = $watchedDirsPath;
}
public function dispatchMetadataAction($md, $mode, $dry_run=false)
{
public function dispatchMetadata($md, $mode, $dry_run=false)
{
// Replace this compound result in a hash with proper error handling later on
$return_hash = array();
if ( $dry_run ) { // for debugging we return garbage not to screw around with the db
@ -587,7 +587,7 @@ class ApiController extends Zend_Controller_Action
// Removing 'mode' key from $info_json might not be necessary...
$mode = $info_json['mode'];
unset( $info_json['mode'] );
$response = $this->dispatchMetadataAction($info_json, $mode, $dry_run=$dry);
$response = $this->dispatchMetadata($info_json, $mode, $dry_run=$dry);
// We tack on the 'key' back to every request in case the would like to associate
// his requests with particular responses
$response['key'] = $k;

View file

@ -451,8 +451,13 @@ class Application_Model_StoredFile
return $baseUrl."/api/get-media/file/".$this->getId().".".$this->getFileExtension();
}
public static function Insert($md=null)
public static function Insert($md)
{
// save some work by checking if filepath is given right away
if( !isset($md['MDATA_KEY_FILEPATH']) ) {
return null;
}
$file = new CcFiles();
$file->setDbUtime(new DateTime("now", new DateTimeZone("UTC")));
$file->setDbMtime(new DateTime("now", new DateTimeZone("UTC")));
@ -460,22 +465,14 @@ class Application_Model_StoredFile
$storedFile = new Application_Model_StoredFile();
$storedFile->_file = $file;
if (isset($md['MDATA_KEY_FILEPATH'])) {
// removed "//" in the path. Always use '/' for path separator
$filepath = str_replace("//", "/", $md['MDATA_KEY_FILEPATH']);
$res = $storedFile->setFilePath($filepath);
if ($res === -1) {
return null;
}
} else {
// removed "//" in the path. Always use '/' for path separator
$filepath = str_replace("//", "/", $md['MDATA_KEY_FILEPATH']);
$res = $storedFile->setFilePath($filepath);
if ($res === -1) {
return null;
}
if (isset($md)) {
$storedFile->setMetadata($md);
}
return $storedFile;
$storedFile->setMetadata($md);
return $storedFile;
}
/**