From ee4ba5d5f2b33e84a1e8938712b0c02abc2d2f58 Mon Sep 17 00:00:00 2001 From: Tomas Date: Thu, 2 Oct 2025 23:40:33 +0200 Subject: [PATCH] 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. --- scraper/server/__main__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scraper/server/__main__.py b/scraper/server/__main__.py index ce7152a..25ae609 100644 --- a/scraper/server/__main__.py +++ b/scraper/server/__main__.py @@ -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)