]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Call flush() in a few more places
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Sun, 31 Oct 2021 21:01:28 +0000 (21:01 +0000)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 1 Nov 2021 09:58:16 +0000 (10:58 +0100)
Since we never explicitly close these files, sometimes the stuff
we write to them doesn't seem to get flushed which causes the
files to be empty in the output directory. Add calls to flush()
to make sure the files aren't empty when mkosi finishes.

mkosi/__init__.py

index e46f353d0c847907f0112fc91914e6084a48cb4d..61a8a48810b33181a8747d14dace156c8e9fc69d 100644 (file)
@@ -4132,6 +4132,7 @@ def write_root_hash_file(args: CommandLineArguments, root_hash: Optional[str]) -
             tempfile.NamedTemporaryFile(mode="w+b", prefix=".mkosi", dir=os.path.dirname(args.output_root_hash_file)),
         )
         f.write((root_hash + "\n").encode())
+        f.flush()
 
     return f
 
@@ -4151,6 +4152,7 @@ def write_root_hash_p7s_file(args: CommandLineArguments, root_hash_p7s: Optional
             ),
         )
         f.write(root_hash_p7s)
+        f.flush()
 
     return f
 
@@ -4171,6 +4173,7 @@ def copy_nspawn_settings(args: CommandLineArguments) -> Optional[BinaryIO]:
 
         with open(args.nspawn_settings, "rb") as c:
             f.write(c.read())
+            f.flush()
 
     return f