From c75248fce8fa4061c6c178b59efcaf00ea7aac9d Mon Sep 17 00:00:00 2001 From: Patrick Renner Date: Fri, 13 Dec 2024 14:51:12 -0600 Subject: [PATCH] write in a with block --- .../src/OpenMediaMatch/blueprints/hashing.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hasher-matcher-actioner/src/OpenMediaMatch/blueprints/hashing.py b/hasher-matcher-actioner/src/OpenMediaMatch/blueprints/hashing.py index d837bc439..d5f8d75c4 100644 --- a/hasher-matcher-actioner/src/OpenMediaMatch/blueprints/hashing.py +++ b/hasher-matcher-actioner/src/OpenMediaMatch/blueprints/hashing.py @@ -55,8 +55,8 @@ def hash_media() -> dict[str, str]: # For images, we may need to copy the file suffix (.png, jpeg, etc) for it to work with tempfile.NamedTemporaryFile("wb") as tmp: current_app.logger.debug("Writing to %s", tmp.name) - tmp.write(download_resp.content) - tmp.flush() # this ensures that bytes from PNGs are written + with tmp.file as temp_file: # this ensures that bytes from PNGs are written + temp_file.write(download_resp.content) path = Path(tmp.name) for st in signal_types.values(): # At this point, every BytesHasher is a FileHasher, but we could