From 4aa233e9e4dd838fe95bdd8b2e44dc0a5cfe61ac Mon Sep 17 00:00:00 2001 From: Patrick Speiser Date: Mon, 3 Sep 2012 23:32:29 +0200 Subject: [PATCH] Better fix for Issue #796, filters all hidden Unix directories --- headphones/librarysync.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/headphones/librarysync.py b/headphones/librarysync.py index 7001c14c..ea95efa6 100644 --- a/headphones/librarysync.py +++ b/headphones/librarysync.py @@ -56,6 +56,11 @@ def libraryScan(dir=None, append=False, ArtistID=None, ArtistName=None): song_list = [] for r,d,f in os.walk(dir): + #need to abuse slicing to get a copy of the list, doing it directly will skip the element after a deleted one + #using a list comprehension will not work correctly for nested subdirectories (os.walk keeps its original list) + for directory in d[:]: + if directory.startswith("."): + d.remove(directory) for files in f: # MEDIA_FORMATS = music file extensions, e.g. mp3, flac, etc if any(files.lower().endswith('.' + x.lower()) for x in headphones.MEDIA_FORMATS):