Let Photo.basename be a @property.

This commit is contained in:
voussoir 2020-09-28 14:06:32 -07:00
parent 3b72b07262
commit 98f706f486

View file

@ -682,7 +682,7 @@ class Photo(ObjectBase):
self.id = db_row['id'] self.id = db_row['id']
self.created = db_row['created'] self.created = db_row['created']
self.author_id = self.normalize_author_id(db_row['author_id']) self.author_id = self.normalize_author_id(db_row['author_id'])
self.basename = db_row['override_filename'] or self.real_path.basename self.override_filename = db_row['override_filename']
self.extension = db_row['extension'] self.extension = db_row['extension']
self.tagged_at = db_row['tagged_at'] self.tagged_at = db_row['tagged_at']
@ -776,6 +776,10 @@ class Photo(ObjectBase):
return tag return tag
@property
def basename(self):
return self.override_filename or self.real_path.basename
@property @property
def bitrate(self): def bitrate(self):
if self.duration and self.bytes is not None: if self.duration and self.bytes is not None:
@ -1196,7 +1200,7 @@ class Photo(ObjectBase):
'override_filename': new_filename, 'override_filename': new_filename,
} }
self.photodb.sql_update(table='photos', pairs=data, where_key='id') self.photodb.sql_update(table='photos', pairs=data, where_key='id')
self.basename = new_filename self.override_filename = new_filename
self.__reinit__() self.__reinit__()