nixos/systemd-boot: fsync() copied files

Since mkstemp() gives us a file descriptor, we may as well call fsync().

Changed files
+4 -3
nixos
modules
system
boot
loader
+4 -3
nixos/modules/system/boot/loader/systemd-boot/systemd-boot-builder.py
···
def copy_if_not_exists(source: Path, dest: Path) -> None:
if not dest.exists():
-
_hdl, tmpfile = tempfile.mkstemp(dir=dest.parent, prefix=dest.name)
-
shutil.copyfile(source, tmpfile)
-
shutil.move(tmpfile, dest)
+
tmpfd, tmppath = tempfile.mkstemp(dir=dest.parent, prefix=dest.name, suffix='.tmp.')
+
shutil.copyfile(source, tmppath)
+
os.fsync(tmpfd)
+
shutil.move(tmppath, dest)
def generation_dir(profile: str | None, generation: int) -> Path: