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: diff --git a/docs/changelog.rst b/docs/changelog.rst index fad853fee..9e9f1c026 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -297,6 +297,9 @@ Bug fixes: * Fix bug where all media types are reported as the first media type when importing with MusicBrainz as the data source :bug:`4947` +* Fix bug where unimported plugin would not ignore children directories of + ignored directories. + :bug:`5130` For plugin developers: