Skip to content

Instantly share code, notes, and snippets.

@sampsyo
Last active August 29, 2015 14:10
Show Gist options
  • Save sampsyo/c3e5dcf26a46719545f1 to your computer and use it in GitHub Desktop.
Save sampsyo/c3e5dcf26a46719545f1 to your computer and use it in GitHub Desktop.
diff --git a/beetsplug/importadded.py b/beetsplug/importadded.py
index d362005..f793761 100644
--- a/beetsplug/importadded.py
+++ b/beetsplug/importadded.py
@@ -107,6 +107,11 @@ def update_album_times(lib, album):
if config['importadded']['preserve_mtimes'].get(bool):
write_item_mtime(item, mtime)
item.store()
+ if not album_mtimes:
+ # There were no mtimes recorded for these tracks. This means that the
+ # album was not moved/copied, so there is nothing to do.
+ log.debug(u'No mtimes for album {0}.'.format(album.album))
+ return
album.added = min(album_mtimes)
log.debug(u"Import of album '{0}', selected album.added={1} from item"
u" file mtimes.".format(album.album, album.added))
diff --git a/docs/changelog.rst b/docs/changelog.rst
index d92d729..8045487 100644
--- a/docs/changelog.rst
+++ b/docs/changelog.rst
@@ -19,7 +19,9 @@ Fixed:
:ref:`import-cmd` command. :bug:`1123`
* When deleting fields with the :ref:`modify-cmd` command, do not crash when
the field cannot be removed (i.e., when it does not exist, when it is a
- built-in field, or when it is a computed field). :ref:`1124`
+ built-in field, or when it is a computed field). :bug:`1124`
+* :doc:`/plugins/importadded`: Avoid a crash when music is neither moved nor
+ copied. :bug:`1107`
.. _Plex: https://plex.tv/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment