From 3bca91e71e43011c8598e15bbb557182a63e9a39 Mon Sep 17 00:00:00 2001 From: Karl Pettersson Date: Wed, 28 Jan 2026 17:21:10 +0100 Subject: [PATCH 1/2] Check image size and pad after closing first with statement. --- lib/generator.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/generator.py b/lib/generator.py index 8913c6c9..d334566c 100755 --- a/lib/generator.py +++ b/lib/generator.py @@ -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: From e013715f43844d70d62dd60178b96e01bdd089c4 Mon Sep 17 00:00:00 2001 From: Karl Pettersson Date: Wed, 28 Jan 2026 17:31:13 +0100 Subject: [PATCH 2/2] Removed trailing whitespace. --- lib/generator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/generator.py b/lib/generator.py index d334566c..9b1f8bce 100755 --- a/lib/generator.py +++ b/lib/generator.py @@ -248,7 +248,7 @@ class Generator(): image_file.write(infile.read().encode()) # Close first with statement before getting file size. - with open(image_file_name, 'ab') as image_file: + 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: