Update preview_images.py

This commit is contained in:
Joachim 2021-11-20 16:26:02 +01:00
parent 37508d2583
commit 40264e372d

View file

@ -316,13 +316,13 @@ def save_and_cleanup(image, instance=None):
"""Save and close the file"""
if not isinstance(instance, (models.Book, models.User, models.SiteSettings)):
return False
uuid = uuid4()
image_buffer = BytesIO()
try:
try:
file_name = instance.preview_image.name
except ValueError:
uuid = uuid4()
file_name = f"{instance.id}-{uuid}.jpg"
# Save