From f8efc9d5696905175c1e2c007f10ffa73c757348 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Fri, 29 Jan 2021 01:07:58 -0800 Subject: [PATCH] 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. --- etiquette/objects.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/etiquette/objects.py b/etiquette/objects.py index 8434d5f..30fa1be 100644 --- a/etiquette/objects.py +++ b/etiquette/objects.py @@ -983,11 +983,13 @@ class Photo(ObjectBase): return_filepath = hopeful_filepath if return_filepath != self.thumbnail: - if return_filepath is not None: - return_filepath = return_filepath.absolute_path + if return_filepath is None: + store_as = None + else: + store_as = return_filepath.relative_to(self.photodb.thumbnail_directory) data = { 'id': self.id, - 'thumbnail': return_filepath, + 'thumbnail': store_as, } self.photodb.sql_update(table='photos', pairs=data, where_key='id') self.thumbnail = return_filepath