cc-4292: Initial fix of the MD5 issue. Now MD5's are only collected not really used for anything. Moves are handled completely

through paths.
This commit is contained in:
Rudi Grinberg 2012-09-11 16:02:39 -04:00
parent 6c1d7fedc1
commit 355b0ad35d
3 changed files with 12 additions and 8 deletions

View File

@ -513,11 +513,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 +661,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

@ -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_MD5'] = self.metadata.extract()['MDATA_KEY_MD5'] req_dict['MDATA_KEY_ORIGINAL_PATH'] = self.old_path()
req_dict['MDATA_KEY_FILEPATH'] = unicode( self.path ) req_dict['MDATA_KEY_FILEPATH'] = unicode( self.path )
req_dict['MDATA_KEY_MD5'] = self.metadata.extract()['MDATA_KEY_MD5']
return [req_dict] return [req_dict]
class ModifyFile(BaseEvent, HasMetaData): class ModifyFile(BaseEvent, HasMetaData):