mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-18 07:33:57 +00:00
See if the image is saved in DB in the Github Actions test environment
This commit is contained in:
parent
b4e2d8c6e3
commit
022182e114
1 changed files with 23 additions and 23 deletions
|
@ -309,33 +309,33 @@ def save_and_cleanup(image, instance=None):
|
|||
file_name = "%s-%s.jpg" % (str(instance.id), str(uuid4()))
|
||||
image_buffer = BytesIO()
|
||||
|
||||
# try:
|
||||
try:
|
||||
try:
|
||||
old_path = instance.preview_image.path
|
||||
except ValueError:
|
||||
old_path = ""
|
||||
old_path = instance.preview_image.path
|
||||
except ValueError:
|
||||
old_path = ""
|
||||
|
||||
# Save
|
||||
image.save(image_buffer, format="jpeg", quality=75)
|
||||
instance.preview_image = InMemoryUploadedFile(
|
||||
ContentFile(image_buffer.getvalue()),
|
||||
"preview_image",
|
||||
file_name,
|
||||
"image/jpg",
|
||||
image_buffer.tell(),
|
||||
None,
|
||||
)
|
||||
# Save
|
||||
image.save(image_buffer, format="jpeg", quality=75)
|
||||
instance.preview_image = InMemoryUploadedFile(
|
||||
ContentFile(image_buffer.getvalue()),
|
||||
"preview_image",
|
||||
file_name,
|
||||
"image/jpg",
|
||||
image_buffer.tell(),
|
||||
None,
|
||||
)
|
||||
|
||||
save_without_broadcast = isinstance(instance, (models.Book, models.User))
|
||||
if save_without_broadcast:
|
||||
instance.save(update_fields=["preview_image"], broadcast=False)
|
||||
else:
|
||||
instance.save(update_fields=["preview_image"])
|
||||
save_without_broadcast = isinstance(instance, (models.Book, models.User))
|
||||
if save_without_broadcast:
|
||||
instance.save(update_fields=["preview_image"], broadcast=False)
|
||||
else:
|
||||
instance.save(update_fields=["preview_image"])
|
||||
|
||||
# Clean up old file after saving
|
||||
if os.path.exists(old_path):
|
||||
os.remove(old_path)
|
||||
finally:
|
||||
# Clean up old file after saving
|
||||
if os.path.exists(old_path):
|
||||
os.remove(old_path)
|
||||
# finally:
|
||||
image_buffer.close()
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue