From b80713ce5b76a5f2db0d73da4f5f50a31c72e116 Mon Sep 17 00:00:00 2001 From: Adrian Sampson Date: Fri, 13 Feb 2015 17:37:55 -0800 Subject: [PATCH] Lambda-free reference to instance method Amends 9cdd541943a481cf7d866cc28f7355f634d0bf1d, the fix for #1326. --- beets/library.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/beets/library.py b/beets/library.py index 4cf1d6d74..8d44455e8 100644 --- a/beets/library.py +++ b/beets/library.py @@ -420,8 +420,7 @@ class Item(LibModel): def _getters(cls): getters = plugins.item_field_getters() getters['singleton'] = lambda i: i.album_id is None - # Filesize is given in bytes - getters['filesize'] = lambda i: i.try_filesize() + getters['filesize'] = Item.try_filesize # In bytes. return getters @classmethod @@ -606,6 +605,10 @@ class Item(LibModel): return int(os.path.getmtime(syspath(self.path))) def try_filesize(self): + """Get the size of the underlying file in bytes. + + If the file is missing, return 0 (and log a warning). + """ try: return os.path.getsize(syspath(self.path)) except (OSError, Exception) as exc: