Store thumbnail paths as relative to datadir.

I went back on this originally, now I'm going... forth on it.
Although the photo files need to be absolute paths, thumbnails should
be relative so you can relocate the photodb and have it still work
properly.
This commit is contained in:
voussoir 2021-01-29 01:07:58 -08:00
parent b5d1c12c11
commit f8efc9d569
No known key found for this signature in database
GPG key ID: 5F7554F8C26DACCB

View file

@ -983,11 +983,13 @@ class Photo(ObjectBase):
return_filepath = hopeful_filepath return_filepath = hopeful_filepath
if return_filepath != self.thumbnail: if return_filepath != self.thumbnail:
if return_filepath is not None: if return_filepath is None:
return_filepath = return_filepath.absolute_path store_as = None
else:
store_as = return_filepath.relative_to(self.photodb.thumbnail_directory)
data = { data = {
'id': self.id, 'id': self.id,
'thumbnail': return_filepath, 'thumbnail': store_as,
} }
self.photodb.sql_update(table='photos', pairs=data, where_key='id') self.photodb.sql_update(table='photos', pairs=data, where_key='id')
self.thumbnail = return_filepath self.thumbnail = return_filepath