cc-2419: media monitor import on start
-send removed file list before added file list
This commit is contained in:
parent
0f67db9ed7
commit
d4e4090429
|
@ -66,7 +66,7 @@ class AirtimeMediaMonitorBootstrap():
|
|||
self.logger.info("Changed files since last checkin:\n%s\n", "\n".join(stdoutSplit))
|
||||
|
||||
for line in stdoutSplit:
|
||||
if len(line.strip(' ')) > 0:
|
||||
if len(line.strip(' ')) > 1:
|
||||
if line[0] == '+':
|
||||
added_files.add(line[1:])
|
||||
elif line[0] == '-':
|
||||
|
@ -87,13 +87,13 @@ class AirtimeMediaMonitorBootstrap():
|
|||
for file_path in new_files:
|
||||
added_files.add(file_path)
|
||||
|
||||
for file_path in removed_files:
|
||||
self.pe.handle_removed_file(file_path)
|
||||
|
||||
for file_path in added_files:
|
||||
if os.path.exists(file_path):
|
||||
self.pe.handle_created_file(False, os.path.basename(file_path), file_path)
|
||||
|
||||
for file_path in removed_files:
|
||||
self.pe.handle_removed_file(file_path)
|
||||
|
||||
def execCommand(self, command):
|
||||
p = Popen(command, shell=True)
|
||||
sts = os.waitpid(p.pid, 0)[1]
|
||||
|
|
|
@ -39,11 +39,6 @@ class AirtimeProcessEvent(ProcessEvent):
|
|||
self.wm = WatchManager()
|
||||
self.md_manager = AirtimeMetadata()
|
||||
|
||||
#Set to "True" everytime we get a file event so
|
||||
#that we can track of when we need to rewrite the
|
||||
#index file
|
||||
self.dirty = False
|
||||
|
||||
#define which directories the pyinotify WatchManager should watch.
|
||||
def watch_directory(self, directory):
|
||||
return self.wm.add_watch(directory, self.mask, rec=True, auto_add=True)
|
||||
|
@ -338,14 +333,11 @@ class AirtimeProcessEvent(ProcessEvent):
|
|||
for event in self.file_events:
|
||||
self.multi_queue.put(event)
|
||||
|
||||
self.dirty = True
|
||||
|
||||
self.file_events = []
|
||||
elif self.multi_queue.empty():
|
||||
#no file_events and queue is empty. This is a good time
|
||||
#to write an index file.
|
||||
if self.dirty:
|
||||
self.write_index_file()
|
||||
self.dirty = False
|
||||
self.write_index_file()
|
||||
|
||||
#check for any events recieved from Airtime.
|
||||
try:
|
||||
|
|
Loading…
Reference in New Issue