Commit 85c7452e authored by sternenseemann's avatar sternenseemann
Browse files

nixos/systemd-boot: fsync() copied files

Since mkstemp() gives us a file descriptor, we may as well call fsync().
parent 94c190a5
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -65,9 +65,10 @@ class SystemIdentifier(NamedTuple):

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: