CC-2927: Media Monitor: if new dir is generated in the process of
importing a file, airtime doesn't import the file. - fixed
This commit is contained in:
parent
109bd5d044
commit
973e934151
|
@ -58,7 +58,7 @@ try:
|
|||
|
||||
|
||||
wm = WatchManager()
|
||||
mmc = MediaMonitorCommon(config)
|
||||
mmc = MediaMonitorCommon(config, wm=wm)
|
||||
pe = AirtimeProcessEvent(queue=multi_queue, airtime_config=config, wm=wm, mmc=mmc, api_client=api_client)
|
||||
|
||||
bootstrap = AirtimeMediaMonitorBootstrap(logger, pe, api_client, mmc)
|
||||
|
|
|
@ -90,12 +90,8 @@ class AirtimeProcessEvent(ProcessEvent):
|
|||
|
||||
def process_IN_CREATE(self, event):
|
||||
self.logger.info("event: %s", event)
|
||||
if not event.dir:
|
||||
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})
|
||||
# record the timestamp of the time on IN_CREATE event
|
||||
self.create_dict[event.pathname] = time.time()
|
||||
|
||||
# record the timestamp of the time on IN_CREATE event
|
||||
self.create_dict[event.pathname] = time.time()
|
||||
|
||||
#event.dir: True if the event was raised against a directory.
|
||||
#event.name: filename
|
||||
|
@ -171,11 +167,6 @@ class AirtimeProcessEvent(ProcessEvent):
|
|||
else:
|
||||
self.cookies_IN_MOVED_FROM[event.cookie] = (event, time.time())
|
||||
|
||||
|
||||
#Some weird thing to note about this event: it seems that if a file is moved to a newly
|
||||
#created directory, then the IN_MOVED_FROM event will be called, but instead of a corresponding
|
||||
#IN_MOVED_TO event, a IN_CREATED event will happen instead. However if the directory existed before
|
||||
#then the IN_MOVED_TO event will be called.
|
||||
def process_IN_MOVED_TO(self, event):
|
||||
self.logger.info("process_IN_MOVED_TO: %s", event)
|
||||
#if stuff dropped in stor via a UI move must change file permissions.
|
||||
|
|
|
@ -6,16 +6,18 @@ import logging
|
|||
from subprocess import Popen, PIPE
|
||||
from airtimemetadata import AirtimeMetadata
|
||||
from api_clients import api_client
|
||||
import pyinotify
|
||||
|
||||
class MediaMonitorCommon:
|
||||
|
||||
timestamp_file = "/var/tmp/airtime/last_index"
|
||||
|
||||
def __init__(self, airtime_config):
|
||||
def __init__(self, airtime_config, wm=None):
|
||||
self.supported_file_formats = ['mp3', 'ogg']
|
||||
self.logger = logging.getLogger()
|
||||
self.config = airtime_config
|
||||
self.md_manager = AirtimeMetadata()
|
||||
self.wm = wm
|
||||
|
||||
def is_parent_directory(self, filepath, directory):
|
||||
filepath = os.path.normpath(filepath)
|
||||
|
@ -85,6 +87,7 @@ class MediaMonitorCommon:
|
|||
omask = os.umask(0)
|
||||
if not os.path.exists(directory):
|
||||
os.makedirs(directory, 02777)
|
||||
self.wm.add_watch(directory, pyinotify.ALL_EVENTS, rec=True, auto_add=True)
|
||||
elif not os.path.isdir(directory):
|
||||
#path exists but it is a file not a directory!
|
||||
self.logger.error("path %s exists, but it is not a directory!!!")
|
||||
|
|
Loading…
Reference in New Issue