CC-2557 : Need to keep tmp file dictionary to change ogg metadata on the server side

This commit is contained in:
Naomi Aro 2011-07-18 12:49:45 +02:00
parent e369ab8dee
commit 91feeaf84d
2 changed files with 35 additions and 29 deletions

View File

@ -31,6 +31,7 @@ class AirtimeProcessEvent(ProcessEvent):
#doesn't need to contact the server and tell it to delete again.
self.ignore_event = set()
self.temp_files = {}
self.cookies_IN_MOVED_FROM = {}
self.file_events = []
self.multi_queue = queue
@ -51,10 +52,12 @@ class AirtimeProcessEvent(ProcessEvent):
if not dir:
self.logger.debug("PROCESS_IN_CREATE: %s, name: %s, pathname: %s ", dir, name, pathname)
#event is because of a created file
#if self.is_temp_file(name) :
if self.mmc.is_temp_file(name) :
#file created is a tmp file which will be modified and then moved back to the original filename.
#self.temp_files[pathname] = None
if self.mmc.is_audio_file(pathname):
#Easy Tag creates this when changing metadata of ogg files.
self.temp_files[pathname] = None
elif self.mmc.is_audio_file(pathname):
if self.mmc.is_parent_directory(pathname, self.config.organize_directory):
#file was created in /srv/airtime/stor/organize. Need to process and move
#to /srv/airtime/stor/imported
@ -89,7 +92,9 @@ class AirtimeProcessEvent(ProcessEvent):
def process_IN_MOVED_FROM(self, event):
self.logger.info("process_IN_MOVED_FROM: %s", event)
if not event.dir:
if not self.mmc.is_parent_directory(event.pathname, self.config.organize_directory):
if event.pathname in self.temp_files:
self.temp_files[event.cookie] = event.pathname
elif not self.mmc.is_parent_directory(event.pathname, self.config.organize_directory):
#we don't care about moved_from events from the organize dir.
if self.mmc.is_audio_file(event.name):
self.cookies_IN_MOVED_FROM[event.cookie] = (event, time.time())
@ -105,7 +110,10 @@ class AirtimeProcessEvent(ProcessEvent):
self.mmc.set_needed_file_permissions(event.pathname, event.dir)
if not event.dir:
if self.mmc.is_audio_file(event.name):
if event.cookie in self.cookies_IN_MOVED_FROM:
if event.cookie in self.temp_files:
self.file_events.append({'filepath': event.pathname, 'mode': self.config.MODE_MODIFY})
del self.temp_files[event.cookie]
elif event.cookie in self.cookies_IN_MOVED_FROM:
#files original location was also in a watched directory
del self.cookies_IN_MOVED_FROM[event.cookie]
if self.mmc.is_parent_directory(event.pathname, self.config.organize_directory):

View File

@ -21,7 +21,6 @@ class MediaMonitorCommon:
directory = os.path.normpath(directory)
return (directory == filepath[0:len(directory)])
"""
def is_temp_file(self, filename):
info = filename.split(".")
@ -29,7 +28,6 @@ class MediaMonitorCommon:
return True
else:
return False
"""
def is_audio_file(self, filename):
info = filename.split(".")