local: Add --clear flag to scanner.

This commit is contained in:
Thomas Adamcik 2013-12-30 01:38:44 +01:00
parent 09c0ae2551
commit 82877ec60f

View File

@ -22,6 +22,11 @@ class LocalCommand(commands.Command):
class ScanCommand(commands.Command):
help = "Scan local media files and populate the local library."
def __init__(self):
super(ScanCommand, self).__init__()
self.add_argument('--clear', action='store_true', dest='clear',
help='Clear out library storage')
def run(self, args, config):
media_dir = config['local']['media_dir']
scan_timeout = config['local']['scan_timeout']
@ -40,6 +45,13 @@ class ScanCommand(commands.Command):
library = libraries[library_name](config)
logger.debug('Using %s as the local library', library_name)
if args.clear:
if library.clear():
logging.info('Library succesfully cleared.')
return 0
logging.warning('Unable to clear library.')
return 1
uri_path_mapping = {}
uris_in_library = set()
uris_to_update = set()