CC-2557 : Need to keep tmp file dictionary to change ogg metadata on the server side
This commit is contained in:
parent
e369ab8dee
commit
91feeaf84d
|
@ -31,6 +31,7 @@ class AirtimeProcessEvent(ProcessEvent):
|
||||||
#doesn't need to contact the server and tell it to delete again.
|
#doesn't need to contact the server and tell it to delete again.
|
||||||
self.ignore_event = set()
|
self.ignore_event = set()
|
||||||
|
|
||||||
|
self.temp_files = {}
|
||||||
self.cookies_IN_MOVED_FROM = {}
|
self.cookies_IN_MOVED_FROM = {}
|
||||||
self.file_events = []
|
self.file_events = []
|
||||||
self.multi_queue = queue
|
self.multi_queue = queue
|
||||||
|
@ -51,10 +52,12 @@ class AirtimeProcessEvent(ProcessEvent):
|
||||||
if not dir:
|
if not dir:
|
||||||
self.logger.debug("PROCESS_IN_CREATE: %s, name: %s, pathname: %s ", dir, name, pathname)
|
self.logger.debug("PROCESS_IN_CREATE: %s, name: %s, pathname: %s ", dir, name, pathname)
|
||||||
#event is because of a created file
|
#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.
|
#file created is a tmp file which will be modified and then moved back to the original filename.
|
||||||
#self.temp_files[pathname] = None
|
#Easy Tag creates this when changing metadata of ogg files.
|
||||||
if self.mmc.is_audio_file(pathname):
|
self.temp_files[pathname] = None
|
||||||
|
elif self.mmc.is_audio_file(pathname):
|
||||||
if self.mmc.is_parent_directory(pathname, self.config.organize_directory):
|
if self.mmc.is_parent_directory(pathname, self.config.organize_directory):
|
||||||
#file was created in /srv/airtime/stor/organize. Need to process and move
|
#file was created in /srv/airtime/stor/organize. Need to process and move
|
||||||
#to /srv/airtime/stor/imported
|
#to /srv/airtime/stor/imported
|
||||||
|
@ -89,7 +92,9 @@ class AirtimeProcessEvent(ProcessEvent):
|
||||||
def process_IN_MOVED_FROM(self, event):
|
def process_IN_MOVED_FROM(self, event):
|
||||||
self.logger.info("process_IN_MOVED_FROM: %s", event)
|
self.logger.info("process_IN_MOVED_FROM: %s", event)
|
||||||
if not event.dir:
|
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.
|
#we don't care about moved_from events from the organize dir.
|
||||||
if self.mmc.is_audio_file(event.name):
|
if self.mmc.is_audio_file(event.name):
|
||||||
self.cookies_IN_MOVED_FROM[event.cookie] = (event, time.time())
|
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)
|
self.mmc.set_needed_file_permissions(event.pathname, event.dir)
|
||||||
if not event.dir:
|
if not event.dir:
|
||||||
if self.mmc.is_audio_file(event.name):
|
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
|
#files original location was also in a watched directory
|
||||||
del self.cookies_IN_MOVED_FROM[event.cookie]
|
del self.cookies_IN_MOVED_FROM[event.cookie]
|
||||||
if self.mmc.is_parent_directory(event.pathname, self.config.organize_directory):
|
if self.mmc.is_parent_directory(event.pathname, self.config.organize_directory):
|
||||||
|
|
|
@ -21,7 +21,6 @@ class MediaMonitorCommon:
|
||||||
directory = os.path.normpath(directory)
|
directory = os.path.normpath(directory)
|
||||||
return (directory == filepath[0:len(directory)])
|
return (directory == filepath[0:len(directory)])
|
||||||
|
|
||||||
"""
|
|
||||||
def is_temp_file(self, filename):
|
def is_temp_file(self, filename):
|
||||||
info = filename.split(".")
|
info = filename.split(".")
|
||||||
|
|
||||||
|
@ -29,7 +28,6 @@ class MediaMonitorCommon:
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
"""
|
|
||||||
|
|
||||||
def is_audio_file(self, filename):
|
def is_audio_file(self, filename):
|
||||||
info = filename.split(".")
|
info = filename.split(".")
|
||||||
|
|
Loading…
Reference in New Issue