diff --git a/python_apps/media-monitor/airtimefilemonitor/airtimemediamonitorbootstrap.py b/python_apps/media-monitor/airtimefilemonitor/airtimemediamonitorbootstrap.py index 63bc69ab6..d6efe9a10 100644 --- a/python_apps/media-monitor/airtimefilemonitor/airtimemediamonitorbootstrap.py +++ b/python_apps/media-monitor/airtimefilemonitor/airtimemediamonitorbootstrap.py @@ -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,12 +87,12 @@ 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) diff --git a/python_apps/media-monitor/airtimefilemonitor/airtimeprocessevent.py b/python_apps/media-monitor/airtimefilemonitor/airtimeprocessevent.py index 846cb3c41..f22ec7993 100644 --- a/python_apps/media-monitor/airtimefilemonitor/airtimeprocessevent.py +++ b/python_apps/media-monitor/airtimefilemonitor/airtimeprocessevent.py @@ -38,11 +38,6 @@ class AirtimeProcessEvent(ProcessEvent): self.mask = pyinotify.ALL_EVENTS 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): @@ -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: