CC-2582 : Files with a tracknumber that isn't actually a tracknumber don't get imported properly

adding more metadata checks so it won't have a database insertion issue.
This commit is contained in:
Naomi Aro 2011-07-22 12:54:42 +02:00
parent 276fa8d99e
commit d3776f4ea9
4 changed files with 15 additions and 30 deletions

View File

@ -454,21 +454,6 @@ class ApiController extends Zend_Controller_Action
return; return;
} }
//Martin Konecny July 14th, 2011: The following commented out code is the way
//we used to check for duplicates (by md5). Why are we checking by md5 and
//not by filepath?
/*
$md5 = $md['MDATA_KEY_MD5'];
$file = StoredFile::RecallByMd5($md5);
if (is_null($file)) {
$file = StoredFile::Insert($md);
}
else {
$this->view->error = "File already exists in Airtime.";
return;
}
*/
} }
else if ($mode == "modify") { else if ($mode == "modify") {
$filepath = $md['MDATA_KEY_FILEPATH']; $filepath = $md['MDATA_KEY_FILEPATH'];

View File

@ -91,13 +91,6 @@ class StoredFile {
} }
} }
public static function getFileCount()
{
global $CC_CONFIG, $CC_DBC;
$sql = "SELECT count(*) as cnt FROM ".$CC_CONFIG["filesTable"];
return $CC_DBC->GetOne($sql);
}
/** /**
* Set multiple metadata values using database columns as indexes. * Set multiple metadata values using database columns as indexes.
* *
@ -826,6 +819,13 @@ class StoredFile {
} }
public static function getFileCount()
{
global $CC_CONFIG, $CC_DBC;
$sql = "SELECT count(*) as cnt FROM ".$CC_CONFIG["filesTable"];
return $CC_DBC->GetOne($sql);
}
public static function listAllFiles($dir_id){ public static function listAllFiles($dir_id){
global $CC_DBC; global $CC_DBC;

View File

@ -139,15 +139,18 @@ class AirtimeMetadata:
if isinstance(md['MDATA_KEY_TRACKNUMBER'], basestring): if isinstance(md['MDATA_KEY_TRACKNUMBER'], basestring):
match = re.search('^(\d*/\d*)?', md['MDATA_KEY_TRACKNUMBER']) match = re.search('^(\d*/\d*)?', md['MDATA_KEY_TRACKNUMBER'])
self.logger.debug('match is')
self.logger.debug(match.group(0))
if match.group(0) is not u'': if match.group(0) is not u'':
md['MDATA_KEY_TRACKNUMBER'] = md['MDATA_KEY_TRACKNUMBER'].split("/")[0] md['MDATA_KEY_TRACKNUMBER'] = md['MDATA_KEY_TRACKNUMBER'].split("/")[0]
self.logger.debug(md['MDATA_KEY_TRACKNUMBER'])
else: else:
del md['MDATA_KEY_TRACKNUMBER'] del md['MDATA_KEY_TRACKNUMBER']
self.logger.debug("deleting tracknumber")
#make sure bpm is valid, need to check more types of formats for this tag to assure correct parsing.
if 'MDATA_KEY_BPM' in md:
if isinstance(md['MDATA_KEY_BPM'], basestring):
try:
md['MDATA_KEY_BPM'] = int(md['MDATA_KEY_BPM'])
except Exception, e:
del md['MDATA_KEY_BPM']
md['MDATA_KEY_BITRATE'] = file_info.info.bitrate md['MDATA_KEY_BITRATE'] = file_info.info.bitrate
md['MDATA_KEY_SAMPLERATE'] = file_info.info.sample_rate md['MDATA_KEY_SAMPLERATE'] = file_info.info.sample_rate

View File

@ -67,14 +67,11 @@ class AirtimeProcessEvent(ProcessEvent):
new_filepath = self.mmc.organize_new_file(pathname) new_filepath = self.mmc.organize_new_file(pathname)
return new_filepath return new_filepath
else: else:
self.logger.debug("setting file permissions")
self.mmc.set_needed_file_permissions(pathname, dir) self.mmc.set_needed_file_permissions(pathname, dir)
self.logger.debug("checking if recorded")
if self.mmc.is_parent_directory(pathname, self.config.recorded_directory): if self.mmc.is_parent_directory(pathname, self.config.recorded_directory):
is_recorded = True is_recorded = True
else : else :
is_recorded = False is_recorded = False
self.logger.debug("appending event")
self.file_events.append({'mode': self.config.MODE_CREATE, 'filepath': pathname, 'is_recorded_show': is_recorded}) self.file_events.append({'mode': self.config.MODE_CREATE, 'filepath': pathname, 'is_recorded_show': is_recorded})
else: else: