Skip to content

Commit

Permalink
Fix firmware.py opening files and not closing
Browse files Browse the repository at this point in the history
  • Loading branch information
tadeubas committed Dec 9, 2024
1 parent c201ff8 commit 7f242e6
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/krux/firmware.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,8 @@ def upgrade():

sig = None
try:
sig = open(firmware_path + ".sig", "rb").read()
with open(firmware_path + ".sig", "rb") as sig_file:
sig = sig_file.read()
except:
display.flash_text(t("Missing signature file"))
return False
Expand Down Expand Up @@ -258,17 +259,19 @@ def status_text(text):
display.clear()
display.draw_centered_text(text)

firmware_file = open(firmware_path, "rb", buffering=0)
write_data(
lambda pct: status_text(
t("Processing..") + "1/3" + "\n\n%d%%" % int(pct * 100)
),
new_address,
open(firmware_path, "rb", buffering=0),
firmware_file,
new_size,
65536,
True,
firmware_with_header_hash,
)
firmware_file.close()

write_data(
lambda pct: status_text(
Expand Down

0 comments on commit 7f242e6

Please sign in to comment.