Skip to content

Commit

Permalink
Unix: use fsync instead of fdatasync to sync the directory
Browse files Browse the repository at this point in the history
fdatasync is not available on MacOS; use fsync instead
  • Loading branch information
andreacorbellini committed Apr 24, 2024
1 parent f579909 commit a8a9cff
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/imp/unix/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use nix::sys::stat::fstatat;
use nix::sys::stat::mode_t;
use nix::sys::stat::Mode;
use nix::unistd::fchown;
use nix::unistd::fdatasync;
use nix::unistd::fsync;
use nix::unistd::unlinkat;
use nix::unistd::Gid;
use nix::unistd::Uid;
Expand Down Expand Up @@ -202,7 +202,7 @@ fn rename_temporary_file(dir: &Dir, temporary_name: &OsStr, name: &OsStr) -> nix
Some(dir.as_raw_fd()),
name,
)?;
fdatasync(dir.as_raw_fd())
fsync(dir.as_raw_fd())
}

fn remove_temporary_file(dir: &Dir, temporary_name: &OsStr) -> nix::Result<()> {
Expand All @@ -211,7 +211,7 @@ fn remove_temporary_file(dir: &Dir, temporary_name: &OsStr) -> nix::Result<()> {
temporary_name,
UnlinkatFlags::NoRemoveDir,
)?;
fdatasync(dir.as_raw_fd())
fsync(dir.as_raw_fd())
}

fn maybe_ignore_eperm(result: nix::Result<()>, preserve: Preserve) -> nix::Result<()> {
Expand Down

0 comments on commit a8a9cff

Please sign in to comment.