CC-2919: Media Monitor: recorded show doesn't show on library after
recording is done - comments were added - timestamps updates with IN_MODIFY
This commit is contained in:
parent
dcda08e17a
commit
109bd5d044
|
@ -93,6 +93,7 @@ class AirtimeProcessEvent(ProcessEvent):
|
||||||
if not event.dir:
|
if not event.dir:
|
||||||
if self.mmc.is_parent_directory(event.pathname, self.config.recorded_directory):
|
if self.mmc.is_parent_directory(event.pathname, self.config.recorded_directory):
|
||||||
self.file_events.append({'mode': self.config.MODE_CREATE, 'filepath': event.pathname, 'is_recorded_show': True})
|
self.file_events.append({'mode': self.config.MODE_CREATE, 'filepath': event.pathname, 'is_recorded_show': True})
|
||||||
|
# record the timestamp of the time on IN_CREATE event
|
||||||
self.create_dict[event.pathname] = time.time()
|
self.create_dict[event.pathname] = time.time()
|
||||||
|
|
||||||
|
|
||||||
|
@ -104,7 +105,9 @@ class AirtimeProcessEvent(ProcessEvent):
|
||||||
def process_IN_CLOSE_WRITE(self, event):
|
def process_IN_CLOSE_WRITE(self, event):
|
||||||
self.logger.info("event: %s", event)
|
self.logger.info("event: %s", event)
|
||||||
self.logger.info("create_dict: %s", self.create_dict)
|
self.logger.info("create_dict: %s", self.create_dict)
|
||||||
|
|
||||||
if event.pathname in self.create_dict:
|
if event.pathname in self.create_dict:
|
||||||
|
# detele corresponding entry from create_dict
|
||||||
self.create_dict.pop(event.pathname)
|
self.create_dict.pop(event.pathname)
|
||||||
self.handle_created_file(event.dir, event.pathname, event.name)
|
self.handle_created_file(event.dir, event.pathname, event.name)
|
||||||
|
|
||||||
|
@ -144,6 +147,9 @@ class AirtimeProcessEvent(ProcessEvent):
|
||||||
self.handle_modified_file(event.dir, event.pathname, event.name)
|
self.handle_modified_file(event.dir, event.pathname, event.name)
|
||||||
|
|
||||||
def handle_modified_file(self, dir, pathname, name):
|
def handle_modified_file(self, dir, pathname, name):
|
||||||
|
# update timestamp on create_dict for the entry with pathname as the key
|
||||||
|
if pathname in self.create_dict:
|
||||||
|
self.create_dict[pathname] = time.time()
|
||||||
if not dir and not self.mmc.is_parent_directory(pathname, self.config.organize_directory):
|
if not dir and not self.mmc.is_parent_directory(pathname, self.config.organize_directory):
|
||||||
self.logger.info("Modified: %s", pathname)
|
self.logger.info("Modified: %s", pathname)
|
||||||
if self.mmc.is_audio_file(name):
|
if self.mmc.is_audio_file(name):
|
||||||
|
@ -267,9 +273,11 @@ class AirtimeProcessEvent(ProcessEvent):
|
||||||
del self.cookies_IN_MOVED_FROM[k]
|
del self.cookies_IN_MOVED_FROM[k]
|
||||||
self.handle_removed_file(False, event.pathname)
|
self.handle_removed_file(False, event.pathname)
|
||||||
|
|
||||||
|
# we don't want create_dict grow infinitely
|
||||||
|
# this part is like a garbage collector
|
||||||
for k, t in self.create_dict.items():
|
for k, t in self.create_dict.items():
|
||||||
now = time.time()
|
now = time.time()
|
||||||
if now - t > 5:
|
if now - t > 300:
|
||||||
del self.create_dict[k]
|
del self.create_dict[k]
|
||||||
|
|
||||||
#check for any events received from Airtime.
|
#check for any events received from Airtime.
|
||||||
|
|
Loading…
Reference in New Issue