diff --git a/python_apps/media-monitor2/media/monitor/airtime.py b/python_apps/media-monitor2/media/monitor/airtime.py index a295686b1..f6df354d4 100644 --- a/python_apps/media-monitor2/media/monitor/airtime.py +++ b/python_apps/media-monitor2/media/monitor/airtime.py @@ -91,7 +91,8 @@ class AirtimeMessageReceiver(Loggable): def _execute_message(self,evt,message): self.dispatch_table[evt](message) - def __request_now_bootstrap(self, directory_id=None, directory=None): + def __request_now_bootstrap(self, directory_id=None, directory=None, + all_files=True): if (not directory_id) and (not directory): raise ValueError("You must provide either directory_id or \ directory") @@ -119,7 +120,7 @@ class AirtimeMessageReceiver(Loggable): self.fatal_exception("Unknown error when writing metadata to: '%s'" % md_path, e) - def new_watch(self, msg): + def new_watch(self, msg, restart=False): msg['directory'] = normpath(msg['directory']) self.logger.info("Creating watch for directory: '%s'" % msg['directory']) @@ -133,7 +134,8 @@ class AirtimeMessageReceiver(Loggable): msg['directory']) self.new_watch(msg) else: - self.__request_now_bootstrap( directory=msg['directory'] ) + self.__request_now_bootstrap( directory=msg['directory'], + all_files=restart) self.manager.add_watch_directory(msg['directory']) def remove_watch(self, msg): diff --git a/python_apps/media-monitor2/media/monitor/bootstrap.py b/python_apps/media-monitor2/media/monitor/bootstrap.py index 1e5bd1a22..0a13ea0b4 100644 --- a/python_apps/media-monitor2/media/monitor/bootstrap.py +++ b/python_apps/media-monitor2/media/monitor/bootstrap.py @@ -26,7 +26,7 @@ class Bootstrapper(Loggable): """ for d in self.db.list_storable_paths(): self.flush_watch(d, last_ran) - def flush_watch(self, directory, last_ran): + def flush_watch(self, directory, last_ran, all_files=False): """ flush a single watch/imported directory. useful when wanting to to rescan, or add a watched/imported directory @@ -44,7 +44,8 @@ class Bootstrapper(Loggable): modded += 1 dispatcher.send(signal=self.watch_signal, sender=self, event=ModifyFile(f)) - db_songs = set(( song for song in self.db.directory_get_files(directory) + db_songs = set(( song for song in self.db.directory_get_files(directory, + all_files) if mmp.sub_path(directory,song) )) # Get all the files that are in the database but in the file # system. These are the files marked for deletions diff --git a/python_apps/media-monitor2/media/monitor/syncdb.py b/python_apps/media-monitor2/media/monitor/syncdb.py index 1f3674e53..0c14fb038 100644 --- a/python_apps/media-monitor2/media/monitor/syncdb.py +++ b/python_apps/media-monitor2/media/monitor/syncdb.py @@ -75,15 +75,15 @@ class AirtimeDB(Loggable): l.append(self.recorded_path()) return l - def dir_id_get_files(self, dir_id): + def dir_id_get_files(self, dir_id, all_files=True): """ Get all files in a directory with id dir_id """ base_dir = self.id_to_dir[ dir_id ] return set(( os.path.join(base_dir,p) for p in - self.apc.list_all_db_files( dir_id ) )) + self.apc.list_all_db_files( dir_id, all_files ) )) - def directory_get_files(self, directory): + def directory_get_files(self, directory, all_files=True): """ returns all the files(recursively) in a directory. a directory is an "actual" directory path instead of its id. This is super hacky because @@ -94,7 +94,8 @@ class AirtimeDB(Loggable): normal_dir = os.path.normpath(unicode(directory)) if normal_dir not in self.dir_to_id: raise NoDirectoryInAirtime( normal_dir, self.dir_to_id ) - all_files = self.dir_id_get_files( self.dir_to_id[normal_dir] ) + all_files = self.dir_id_get_files( self.dir_to_id[normal_dir], + all_files ) if normal_dir == self.recorded_path(): all_files = [ p for p in all_files if mmp.sub_path( self.recorded_path(), p ) ]