From 2fbbf522cef4f5a708a416276be2f1661a937bef Mon Sep 17 00:00:00 2001 From: Joachim Date: Sat, 19 Jun 2021 17:46:18 +0200 Subject: [PATCH] Update preview_images.py --- bookwyrm/preview_images.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bookwyrm/preview_images.py b/bookwyrm/preview_images.py index ea32d70a..29c4961c 100644 --- a/bookwyrm/preview_images.py +++ b/bookwyrm/preview_images.py @@ -322,7 +322,7 @@ def save_and_cleanup(image, instance=None): try: old_path = instance.preview_image.name except ValueError: - old_path = "" + old_path = None # Save image.save(image_buffer, format="jpeg", quality=75) @@ -343,7 +343,7 @@ def save_and_cleanup(image, instance=None): instance.save() # Clean up old file after saving - if default_storage.exists(old_path): + if old_path and default_storage.exists(old_path): default_storage.delete(old_path) finally: