diff options
author | Dr-Blank <64108942+Dr-Blank@users.noreply.github.com> | 2024-03-22 18:20:47 -0400 |
---|---|---|
committer | Dr-Blank <64108942+Dr-Blank@users.noreply.github.com> | 2024-03-22 18:20:47 -0400 |
commit | c88953805ba400f8809361d819e92315eb6b9c19 (patch) | |
tree | be8aa25339f364f3d5766bd6e88ae133aa364ea9 | |
parent | b09806e0df8f01b9155017d3693764ae7beedcd5 (diff) |
bugfix: ignore subdirectories of ignored
directories in unimported plugin
-rw-r--r-- | beetsplug/unimported.py | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/beetsplug/unimported.py b/beetsplug/unimported.py index 278fd667c..b473a346a 100644 --- a/beetsplug/unimported.py +++ b/beetsplug/unimported.py @@ -41,15 +41,17 @@ class Unimported(BeetsPlugin): os.path.join(lib.directory, x.encode()) for x in self.config["ignore_subdirectories"].as_str_seq() ] - in_folder = { - os.path.join(r, file) - for r, d, f in os.walk(lib.directory) - for file in f - if not any( - [file.endswith(ext) for ext in ignore_exts] - + [r in ignore_dirs] - ) - } + in_folder = set() + for root, _, files in os.walk(lib.directory): + # do not traverse if root is a child of an ignored directory + if any(root.startswith(ignored) for ignored in ignore_dirs): + continue + for file in files: + # ignore files with ignored extensions + if any(file.endswith(ext) for ext in ignore_exts): + continue + in_folder.add(os.path.join(root, file)) + in_library = {x.path for x in lib.items()} art_files = {x.artpath for x in lib.albums()} for f in in_folder - in_library - art_files: |