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:
@ -124,8 +124,9 @@ def get_image(post_id: int = None):
|
|||||||
return send_file(path)
|
return send_file(path)
|
||||||
else:
|
else:
|
||||||
post = py34.Post(entry.post, entry.dir, entry.image, entry.tags, entry.thumbnail)
|
post = py34.Post(entry.post, entry.dir, entry.image, entry.tags, entry.thumbnail)
|
||||||
|
image = post.get_image_data()
|
||||||
with open(path, "wb") as file:
|
with open(path, "wb") as file:
|
||||||
file.write(post.get_image_data())
|
file.write(image)
|
||||||
return send_file(path)
|
return send_file(path)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user