From fac13a041ed9f59ed9e21d608651a4dcd8e8be84 Mon Sep 17 00:00:00 2001 From: Adrian Sampson Date: Sun, 13 Oct 2013 18:22:43 -0700 Subject: [PATCH] missing: tolerate disctotal == None This problem: http://pastebin.ca/2466454 is likely indicative of a bug elsewhere, but defensive coding seems like a good idea here. --- beetsplug/missing.py | 2 +- docs/changelog.rst | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/beetsplug/missing.py b/beetsplug/missing.py index 0b12ebde6..fe2265da2 100644 --- a/beetsplug/missing.py +++ b/beetsplug/missing.py @@ -28,7 +28,7 @@ log = logging.getLogger('beets') def _missing_count(album): """Return number of missing items in `album`. """ - return album.tracktotal - len([i for i in album.items()]) + return (album.tracktotal or 0) - len(album.items()) def _missing(album): diff --git a/docs/changelog.rst b/docs/changelog.rst index e39c78c6c..b1819eeae 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -4,6 +4,10 @@ Changelog 1.3.2 (in development) ---------------------- +Little fixes: + +* :doc:`/plugins/missing`: Avoid a possible error when an album's + ``tracktotal`` field is missing. 1.3.1 (October 12, 2013) ------------------------