mirror of
https://github.com/aljazceru/turso.git
synced 2026-01-08 10:44:20 +01:00
Merge 'Switch to F_FULLSYNC on Darwin' from
Closes #2743 . Closes #2766
This commit is contained in:
@@ -259,12 +259,32 @@ impl File for UnixFile {
|
||||
#[instrument(err, skip_all, level = Level::TRACE)]
|
||||
fn sync(&self, c: Completion) -> Result<Completion> {
|
||||
let file = self.file.lock();
|
||||
let result = unsafe { libc::fsync(file.as_raw_fd()) };
|
||||
|
||||
let result = unsafe {
|
||||
|
||||
#[cfg(not(any(target_os = "macos", target_os = "ios")))]
|
||||
{
|
||||
libc::fsync(file.as_raw_fd())
|
||||
}
|
||||
|
||||
#[cfg(any(target_os = "macos", target_os = "ios"))]
|
||||
{
|
||||
libc::fcntl(file.as_raw_fd(), libc::F_FULLFSYNC)
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
if result == -1 {
|
||||
let e = std::io::Error::last_os_error();
|
||||
Err(e.into())
|
||||
} else {
|
||||
|
||||
#[cfg(not(any(target_os = "macos", target_os = "ios")))]
|
||||
trace!("fsync");
|
||||
|
||||
#[cfg(any(target_os = "macos", target_os = "ios"))]
|
||||
trace!("fcntl(F_FULLSYNC)");
|
||||
|
||||
c.complete(0);
|
||||
Ok(c)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user