From 58d450a8567a38239c7d7f5c45516b6ac20dc03a Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Tue, 1 May 2018 20:41:38 -0700 Subject: [PATCH] Fix handling of the event that a file loses its thumbnail. In which case return_filepath is None and the relative_to breaks. --- etiquette/objects.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/etiquette/objects.py b/etiquette/objects.py index 5b90195..c959138 100644 --- a/etiquette/objects.py +++ b/etiquette/objects.py @@ -830,9 +830,11 @@ class Photo(ObjectBase): return_filepath = hopeful_filepath if return_filepath != self.thumbnail: + if return_filepath is not None: + return_filepath = return_filepath.relative_to(self.photodb.thumbnail_directory) data = { 'id': self.id, - 'thumbnail': return_filepath.relative_to(self.photodb.thumbnail_directory), + 'thumbnail': return_filepath, } self.photodb.sql_update(table='photos', pairs=data, where_key='id') self.thumbnail = return_filepath