local: Move Hidden file/directory check to excluded extensions check

This commit is contained in:
Thomas Adamcik 2014-10-17 16:52:01 +02:00
parent 43d8062094
commit d4f47a34c2

View File

@ -76,13 +76,6 @@ class ScanCommand(commands.Command):
file_mtimes, file_errors = path.find_mtimes(media_dir)
# TODO: Not sure if we want to keep this, but for now lets filter these
# Could be replaced with passing in a predicate to the find function?
for name in file_mtimes.keys():
if b'/.' in name:
logger.debug('Skipping hidden file/directory: %r', name)
del file_mtimes[name]
logger.info('Found %d files in media_dir.', len(file_mtimes))
if file_errors:
@ -111,11 +104,13 @@ class ScanCommand(commands.Command):
relpath = os.path.relpath(abspath, media_dir)
uri = translator.path_to_local_track_uri(relpath)
if relpath.lower().endswith(excluded_file_extensions):
# TODO: move these to a "predicate" check in the finder?
if b'/.' in relpath:
logger.debug('Skipped %s: Hidden directory/file.', uri)
elif relpath.lower().endswith(excluded_file_extensions):
logger.debug('Skipped %s: File extension excluded.', uri)
continue
uris_to_update.add(uri)
else:
uris_to_update.add(uri)
logger.info(
'Found %d tracks which need to be updated.', len(uris_to_update))