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))
|
self.logger.info("Changed files since last checkin:\n%s\n", "\n".join(stdoutSplit))
|
||||||
|
|
||||||
for line in stdoutSplit:
|
for line in stdoutSplit:
|
||||||
if len(line.strip(' ')) > 0:
|
if len(line.strip(' ')) > 1:
|
||||||
if line[0] == '+':
|
if line[0] == '+':
|
||||||
added_files.add(line[1:])
|
added_files.add(line[1:])
|
||||||
elif line[0] == '-':
|
elif line[0] == '-':
|
||||||
|
@ -87,13 +87,13 @@ class AirtimeMediaMonitorBootstrap():
|
||||||
for file_path in new_files:
|
for file_path in new_files:
|
||||||
added_files.add(file_path)
|
added_files.add(file_path)
|
||||||
|
|
||||||
|
for file_path in removed_files:
|
||||||
|
self.pe.handle_removed_file(file_path)
|
||||||
|
|
||||||
for file_path in added_files:
|
for file_path in added_files:
|
||||||
if os.path.exists(file_path):
|
if os.path.exists(file_path):
|
||||||
self.pe.handle_created_file(False, os.path.basename(file_path), 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):
|
def execCommand(self, command):
|
||||||
p = Popen(command, shell=True)
|
p = Popen(command, shell=True)
|
||||||
sts = os.waitpid(p.pid, 0)[1]
|
sts = os.waitpid(p.pid, 0)[1]
|
||||||
|
|
|
@ -39,11 +39,6 @@ class AirtimeProcessEvent(ProcessEvent):
|
||||||
self.wm = WatchManager()
|
self.wm = WatchManager()
|
||||||
self.md_manager = AirtimeMetadata()
|
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.
|
#define which directories the pyinotify WatchManager should watch.
|
||||||
def watch_directory(self, directory):
|
def watch_directory(self, directory):
|
||||||
return self.wm.add_watch(directory, self.mask, rec=True, auto_add=True)
|
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:
|
for event in self.file_events:
|
||||||
self.multi_queue.put(event)
|
self.multi_queue.put(event)
|
||||||
|
|
||||||
self.dirty = True
|
|
||||||
self.file_events = []
|
self.file_events = []
|
||||||
elif self.multi_queue.empty():
|
|
||||||
#no file_events and queue is empty. This is a good time
|
#no file_events and queue is empty. This is a good time
|
||||||
#to write an index file.
|
#to write an index file.
|
||||||
if self.dirty:
|
|
||||||
self.write_index_file()
|
self.write_index_file()
|
||||||
self.dirty = False
|
|
||||||
|
|
||||||
#check for any events recieved from Airtime.
|
#check for any events recieved from Airtime.
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in New Issue