Check image size and pad after closing first with statement.

This commit is contained in:
Karl Pettersson 2026-01-28 17:21:10 +01:00
parent f81e9fe80f
commit 3bca91e71e

View file

@ -246,6 +246,9 @@ class Generator():
with open(os.path.join('builder-hex0', 'builder-hex0-x86-stage2.hex0'),
encoding="utf-8") as infile:
image_file.write(infile.read().encode())
# Close first with statement before getting file size.
with open(image_file_name, 'ab') as image_file:
# Pad to next sector
current_size = os.stat(image_file_name).st_size
while current_size % 512 != 0: