Merge branch 'devel' of dev.sourcefabric.org:airtime into devel
This commit is contained in:
commit
6c54605327
|
@ -91,7 +91,8 @@ class AirtimeMessageReceiver(Loggable):
|
||||||
def _execute_message(self,evt,message):
|
def _execute_message(self,evt,message):
|
||||||
self.dispatch_table[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):
|
if (not directory_id) and (not directory):
|
||||||
raise ValueError("You must provide either directory_id or \
|
raise ValueError("You must provide either directory_id or \
|
||||||
directory")
|
directory")
|
||||||
|
@ -119,7 +120,7 @@ class AirtimeMessageReceiver(Loggable):
|
||||||
self.fatal_exception("Unknown error when writing metadata to: '%s'"
|
self.fatal_exception("Unknown error when writing metadata to: '%s'"
|
||||||
% md_path, e)
|
% md_path, e)
|
||||||
|
|
||||||
def new_watch(self, msg):
|
def new_watch(self, msg, restart=False):
|
||||||
msg['directory'] = normpath(msg['directory'])
|
msg['directory'] = normpath(msg['directory'])
|
||||||
self.logger.info("Creating watch for directory: '%s'" %
|
self.logger.info("Creating watch for directory: '%s'" %
|
||||||
msg['directory'])
|
msg['directory'])
|
||||||
|
@ -133,7 +134,8 @@ class AirtimeMessageReceiver(Loggable):
|
||||||
msg['directory'])
|
msg['directory'])
|
||||||
self.new_watch(msg)
|
self.new_watch(msg)
|
||||||
else:
|
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'])
|
self.manager.add_watch_directory(msg['directory'])
|
||||||
|
|
||||||
def remove_watch(self, msg):
|
def remove_watch(self, msg):
|
||||||
|
|
|
@ -26,7 +26,7 @@ class Bootstrapper(Loggable):
|
||||||
"""
|
"""
|
||||||
for d in self.db.list_storable_paths(): self.flush_watch(d, last_ran)
|
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
|
flush a single watch/imported directory. useful when wanting to to
|
||||||
rescan, or add a watched/imported directory
|
rescan, or add a watched/imported directory
|
||||||
|
@ -44,7 +44,8 @@ class Bootstrapper(Loggable):
|
||||||
modded += 1
|
modded += 1
|
||||||
dispatcher.send(signal=self.watch_signal, sender=self,
|
dispatcher.send(signal=self.watch_signal, sender=self,
|
||||||
event=ModifyFile(f))
|
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) ))
|
if mmp.sub_path(directory,song) ))
|
||||||
# Get all the files that are in the database but in the file
|
# Get all the files that are in the database but in the file
|
||||||
# system. These are the files marked for deletions
|
# system. These are the files marked for deletions
|
||||||
|
|
|
@ -75,15 +75,15 @@ class AirtimeDB(Loggable):
|
||||||
l.append(self.recorded_path())
|
l.append(self.recorded_path())
|
||||||
return l
|
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
|
Get all files in a directory with id dir_id
|
||||||
"""
|
"""
|
||||||
base_dir = self.id_to_dir[ dir_id ]
|
base_dir = self.id_to_dir[ dir_id ]
|
||||||
return set(( os.path.join(base_dir,p) for p in
|
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
|
returns all the files(recursively) in a directory. a directory is an
|
||||||
"actual" directory path instead of its id. This is super hacky because
|
"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))
|
normal_dir = os.path.normpath(unicode(directory))
|
||||||
if normal_dir not in self.dir_to_id:
|
if normal_dir not in self.dir_to_id:
|
||||||
raise NoDirectoryInAirtime( normal_dir, 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():
|
if normal_dir == self.recorded_path():
|
||||||
all_files = [ p for p in all_files if
|
all_files = [ p for p in all_files if
|
||||||
mmp.sub_path( self.recorded_path(), p ) ]
|
mmp.sub_path( self.recorded_path(), p ) ]
|
||||||
|
|
Loading…
Reference in New Issue