Create file after the image was retrieved

`post.get_image_data()` can throw, creating file and later calling the function can create empty "image" files, confusing the program.
This commit is contained in:
2025-10-02 23:40:33 +02:00
parent 217595fcdd
commit ee4ba5d5f2

View File

@ -124,8 +124,9 @@ def get_image(post_id: int = None):
return send_file(path)
else:
post = py34.Post(entry.post, entry.dir, entry.image, entry.tags, entry.thumbnail)
image = post.get_image_data()
with open(path, "wb") as file:
file.write(post.get_image_data())
file.write(image)
return send_file(path)