From 45d8809971d59ba365ac878b91aa4e9154ea6b14 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Fri, 28 Aug 2020 17:32:53 -0700 Subject: [PATCH] Fix crash while trying to get size of deleted file. Pathclass no longer returns None for missing files, as it did when this was written. --- etiquette/objects.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/etiquette/objects.py b/etiquette/objects.py index 26cae62..cb0907b 100644 --- a/etiquette/objects.py +++ b/etiquette/objects.py @@ -893,15 +893,22 @@ class Photo(ObjectBase): ''' self.photodb.log.debug('Reloading metadata for %s', self) - # If the file has disappeared, this will just return None. - self.bytes = self.real_path.size + self.bytes = None self.width = None self.height = None self.area = None self.ratio = None self.duration = None - if self.simple_mimetype == 'image': + try: + self.bytes = self.real_path.size + except pathclass.NotExists: + pass + + if self.bytes is None: + pass + + elif self.simple_mimetype == 'image': try: image = PIL.Image.open(self.real_path.absolute_path) except (OSError, ValueError):