From c5b3c65ea10a8634960c64254159d03b8d84a4d3 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Mon, 4 Oct 2021 17:23:58 -0700 Subject: [PATCH] Fix hasty and irresponsible leftover site_thumbnails in db. There was a brief period where the thumbnail filepaths were stored in full, now they are stored relative to the thumb directory. But those leftover full paths need to be altered. --- utilities/database_upgrader.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/utilities/database_upgrader.py b/utilities/database_upgrader.py index 64de8d8..39bace3 100644 --- a/utilities/database_upgrader.py +++ b/utilities/database_upgrader.py @@ -667,7 +667,10 @@ def upgrade_19_to_20(photodb): raise Exception(f'{new.absolute_path} already has items in it.') else: os.rmdir(new.absolute_path) - os.rename(old.absolute_path, new.absolute_path) + + photodb.execute('UPDATE photos SET thumbnail = REPLACE(thumbnail, "/site_thumbnails/", "/thumbnails/")') + photodb.execute('UPDATE photos SET thumbnail = REPLACE(thumbnail, "\\site_thumbnails\\", "\\thumbnails\\")') + photodb.on_commit_queue.append({'action': os.rename, 'args': (old.absolute_path, new.absolute_path)}) def upgrade_all(data_directory): '''