Skip to content

Commit

Permalink
write in a with block
Browse files Browse the repository at this point in the history
  • Loading branch information
prenner committed Dec 13, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent ee70457 commit c75248f
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit c75248f

Please sign in to comment.