diff --git a/beets/importer.py b/beets/importer.py index 8ad8eca70..2e1c3b94f 100644 --- a/beets/importer.py +++ b/beets/importer.py @@ -513,11 +513,9 @@ class ImportTask(object): call when the file in question may not have been removed. """ if self.toppath and not os.path.exists(filename): - util.prune_dirs( - os.path.dirname(filename), - self.toppath, - clutter=config['clutter'].get(list) - ) + util.prune_dirs(os.path.dirname(filename), + self.toppath, + clutter=config['clutter'].get(list)) # Full-album pipeline stages. diff --git a/beets/util/__init__.py b/beets/util/__init__.py index 096cc319c..4d5f9fe0e 100644 --- a/beets/util/__init__.py +++ b/beets/util/__init__.py @@ -194,9 +194,8 @@ def mkdirall(path): traceback.format_exc()) def fnmatch_all(names, patterns): - """ - `names` and `patterns` should be iterables. - Returns True if all names match any of the patterns. + """Determine whether all strings in `names` match at least one of + the `patterns`, which should be shell glob expressions. """ for name in names: matches = False @@ -204,7 +203,7 @@ def fnmatch_all(names, patterns): matches = fnmatch.fnmatch(name, pattern) if matches: break - if not matches: + if not matches: return False return True @@ -244,7 +243,7 @@ def prune_dirs(path, root=None, clutter=('.DS_Store', 'Thumbs.db')): try: shutil.rmtree(directory) except OSError: - break + break else: break diff --git a/docs/changelog.rst b/docs/changelog.rst index 360d5e2af..b32a39110 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -10,6 +10,8 @@ New configuration options: is when considering a candidate. * :ref:`none_rec_action` lets you skip the prompt, and automatically choose an action, when there is no good candidate. Thanks to mrmachine. +* :ref:`clutter` controls which files should be ignored when cleaning up empty + directories. Thanks to Steinþór Pálsson. * :doc:`/plugins/lastgenre`: A new configuration option lets you choose to retrieve artist-level tags as genres instead of album- or track-level tags. Thanks to Peter Fern. diff --git a/docs/reference/config.rst b/docs/reference/config.rst index e7cb75be3..f73ac7220 100644 --- a/docs/reference/config.rst +++ b/docs/reference/config.rst @@ -179,6 +179,16 @@ environment variables. .. _known to python: http://docs.python.org/2/library/codecs.html#standard-encodings +.. _clutter: + +clutter +------- + +When beets imports all the files in a directory, it tries to remove the +directory if it's empty. A directory is considered empty if it only contains +files whose names match the glob patterns in `clutter`, which should be a list +of strings. The default list consists of "Thumbs.DB" and ".DS_Store". + Importer Options ----------------