Merge branch 'devel' of dev.sourcefabric.org:airtime into devel

This commit is contained in:
denise 2012-09-11 17:19:12 -04:00
commit c6ab540120
6 changed files with 36 additions and 27 deletions

View File

@ -454,6 +454,8 @@ class ApiController extends Zend_Controller_Action
$showCanceled = true; $showCanceled = true;
} }
// TODO : the following is inefficient because it calls save on both
// fields
$file->setMetadataValue('MDATA_KEY_CREATOR', "Airtime Show Recorder"); $file->setMetadataValue('MDATA_KEY_CREATOR', "Airtime Show Recorder");
$file->setMetadataValue('MDATA_KEY_TRACKNUMBER', $show_instance_id); $file->setMetadataValue('MDATA_KEY_TRACKNUMBER', $show_instance_id);
@ -513,11 +515,11 @@ class ApiController extends Zend_Controller_Action
$file->setMetadata($md); $file->setMetadata($md);
} }
} elseif ($mode == "moved") { } elseif ($mode == "moved") {
$md5 = $md['MDATA_KEY_MD5']; $file = Application_Model_StoredFile::RecallByFilepath(
$file = Application_Model_StoredFile::RecallByMd5($md5); $md['MDATA_KEY_ORIGINAL_PATH']);
if (is_null($file)) { if (is_null($file)) {
return "File doesn't exist in Airtime."; $return_hash['error'] = 'File does not exist in Airtime';
} else { } else {
$filepath = $md['MDATA_KEY_FILEPATH']; $filepath = $md['MDATA_KEY_FILEPATH'];
//$filepath = str_replace("\\", "", $filepath); //$filepath = str_replace("\\", "", $filepath);
@ -661,6 +663,7 @@ class ApiController extends Zend_Controller_Action
} }
} elseif ($mode == "moved") { } elseif ($mode == "moved") {
$md5 = $md['MDATA_KEY_MD5']; $md5 = $md['MDATA_KEY_MD5'];
Logging::info("Original path: {$md['MDATA_KEY_ORIGINAL_PATH']}");
$file = Application_Model_StoredFile::RecallByMd5($md5); $file = Application_Model_StoredFile::RecallByMd5($md5);
if (is_null($file)) { if (is_null($file)) {

View File

@ -226,6 +226,7 @@ class Application_Model_StoredFile
return; return;
} }
if (isset($this->_dbMD[$p_category])) { if (isset($this->_dbMD[$p_category])) {
// TODO : fix this crust -- RG
$propelColumn = $this->_dbMD[$p_category]; $propelColumn = $this->_dbMD[$p_category];
$method = "set$propelColumn"; $method = "set$propelColumn";
$this->_file->$method($p_value); $this->_file->$method($p_value);
@ -315,12 +316,13 @@ class Application_Model_StoredFile
*/ */
public function getPlaylists() public function getPlaylists()
{ {
global $CC_CONFIG;
$con = Propel::getConnection(); $con = Propel::getConnection();
$sql = "SELECT playlist_id " $sql = <<<SQL
." FROM cc_playlist" SELECT playlist_id
." WHERE file_id = :file_id"; FROM cc_playlist
WHERE file_id = :file_id
SQL;
$stmt = $con->prepare($sql); $stmt = $con->prepare($sql);
$stmt->bindParam(':file_id', $this->id, PDO::PARAM_INT); $stmt->bindParam(':file_id', $this->id, PDO::PARAM_INT);
@ -332,14 +334,13 @@ class Application_Model_StoredFile
throw new Exception("Error: $msg"); throw new Exception("Error: $msg");
} }
$playlists = array();
if (is_array($ids) && count($ids) > 0) { if (is_array($ids) && count($ids) > 0) {
foreach ($ids as $id) { return array_map( function ($id) {
$playlists[] = Application_Model_Playlist::Recall($id); return Application_Model_Playlist::Recall($id);
} }, $ids);
} else {
return array();
} }
return $playlists;
} }
/** /**
@ -593,7 +594,6 @@ class Application_Model_StoredFile
public function getName() public function getName()
{ {
$info = pathinfo($this->getFilePath()); $info = pathinfo($this->getFilePath());
return $info['filename']; return $info['filename'];
} }
@ -1024,11 +1024,8 @@ class Application_Model_StoredFile
public static function getFileCount() public static function getFileCount()
{ {
global $CC_CONFIG;
$con = Propel::getConnection(); $con = Propel::getConnection();
$sql = "SELECT count(*) as cnt FROM cc_files WHERE file_exists"; $sql = "SELECT count(*) as cnt FROM cc_files WHERE file_exists";
return $con->query($sql)->fetchColumn(0); return $con->query($sql)->fetchColumn(0);
} }
@ -1101,10 +1098,14 @@ class Application_Model_StoredFile
try { try {
$con = Propel::getConnection(); $con = Propel::getConnection();
$sql = "SELECT soundcloud_id as id, soundcloud_upload_time" $sql = <<<SQL
." FROM CC_FILES" SELECT soundcloud_id AS id,
." WHERE (id != -2 and id != -3) and" soundcloud_upload_time
." (soundcloud_upload_time >= (now() - (INTERVAL '1 day')))"; FROM CC_FILES
WHERE (id != -2
AND id != -3)
AND (soundcloud_upload_time >= (now() - (INTERVAL '1 day')))
SQL;
$rows = $con->query($sql)->fetchAll(); $rows = $con->query($sql)->fetchAll();

View File

@ -46,7 +46,7 @@ class Application_Model_Webstream implements Application_Model_LibraryEditable
$di = new DateInterval("PT{$hours}H{$min}M{$sec}S"); $di = new DateInterval("PT{$hours}H{$min}M{$sec}S");
return $di->format("%Hh %Im"); return $di->format("%Hh %Im");
} }
return ""; return "";
} }

View File

@ -135,7 +135,7 @@ class AirtimeMessageReceiver(Loggable):
msg['directory']) msg['directory'])
self.new_watch(msg) self.new_watch(msg)
else: else:
self.__reFalsequest_now_bootstrap( directory=msg['directory'], self.__request_now_bootstrap( directory=msg['directory'],
all_files=restart) all_files=restart)
self.manager.add_watch_directory(msg['directory']) self.manager.add_watch_directory(msg['directory'])

View File

@ -110,7 +110,7 @@ class BaseEvent(Loggable):
# nothing to see here, please move along # nothing to see here, please move along
def morph_into(self, evt): def morph_into(self, evt):
self.logger.info("Morphing %s into %s" % ( str(self), str(evt) ) ) self.logger.info("Morphing %s into %s" % ( str(self), str(evt) ) )
self._raw_event = evt self._raw_event = evt._raw_event
self.path = evt.path self.path = evt.path
self.__class__ = evt.__class__ self.__class__ = evt.__class__
# Clean up old hook and transfer the new events hook # Clean up old hook and transfer the new events hook
@ -181,11 +181,14 @@ class MoveFile(BaseEvent, HasMetaData):
""" """
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super(MoveFile, self).__init__(*args, **kwargs) super(MoveFile, self).__init__(*args, **kwargs)
def old_path(self):
return self._raw_event.src_pathname
def pack(self): def pack(self):
req_dict = {} req_dict = {}
req_dict['mode'] = u'moved' req_dict['mode'] = u'moved'
req_dict['MDATA_KEY_ORIGINAL_PATH'] = self.old_path()
req_dict['MDATA_KEY_FILEPATH'] = unicode( self.path )
req_dict['MDATA_KEY_MD5'] = self.metadata.extract()['MDATA_KEY_MD5'] req_dict['MDATA_KEY_MD5'] = self.metadata.extract()['MDATA_KEY_MD5']
req_dict['MDATA_KEY_FILEPATH'] = unicode( self.path )
return [req_dict] return [req_dict]
class ModifyFile(BaseEvent, HasMetaData): class ModifyFile(BaseEvent, HasMetaData):

View File

@ -231,6 +231,8 @@ class Manager(Loggable):
else: else:
self.logger.info("'%s' is not being watched, hence cannot be \ self.logger.info("'%s' is not being watched, hence cannot be \
removed" % watch_dir) removed" % watch_dir)
self.logger.info("The directories we are watching now are:")
self.logger.info( self.__wd_path )
def loop(self): def loop(self):
""" """