Move thumbnail work to normalize_thumbnail.

master
voussoir 2021-01-19 10:35:09 -08:00
parent be7f5ebb01
commit a6f9d1859e
No known key found for this signature in database
GPG Key ID: 5F7554F8C26DACCB
1 changed files with 11 additions and 4 deletions

View File

@ -767,10 +767,7 @@ class Photo(ObjectBase):
self.height = db_row['height']
self.ratio = db_row['ratio']
if db_row['thumbnail'] is not None:
self.thumbnail = self.photodb.thumbnail_directory.join(db_row['thumbnail'])
else:
self.thumbnail = None
self.thumbnail = self.normalize_thumbnail(db_row['thumbnail'])
self.searchhidden = db_row['searchhidden']
@ -786,6 +783,16 @@ class Photo(ObjectBase):
def __str__(self):
return f'Photo:{self.id}:{self.basename}'
def normalize_thumbnail(self, thumbnail):
if thumbnail is None:
return None
thumbnail = self.photodb.thumbnail_directory.join(thumbnail)
if not thumbnail.is_file:
return None
return thumbnail
@staticmethod
def normalize_override_filename(override_filename):
if override_filename is None: