@@ -9,9 +9,6 @@ use std::path::{Path, PathBuf};
9
9
use std:: sync:: atomic:: { AtomicUsize , Ordering } ;
10
10
use std:: sync:: { Arc , Mutex , RwLock } ;
11
11
12
- #[ cfg( not( target_os = "windows" ) ) ]
13
- use std:: os:: unix:: io:: AsRawFd ;
14
-
15
12
#[ cfg( target_os = "windows" ) ]
16
13
use { std:: ffi:: OsStr , std:: os:: windows:: ffi:: OsStrExt } ;
17
14
@@ -134,9 +131,7 @@ impl KVStore for FilesystemStore {
134
131
{
135
132
fs:: rename ( & tmp_file_path, & dest_file_path) ?;
136
133
let dir_file = fs:: OpenOptions :: new ( ) . read ( true ) . open ( & parent_directory) ?;
137
- unsafe {
138
- libc:: fsync ( dir_file. as_raw_fd ( ) ) ;
139
- }
134
+ dir_file. sync_all ( ) ?;
140
135
Ok ( ( ) )
141
136
}
142
137
@@ -204,15 +199,13 @@ impl KVStore for FilesystemStore {
204
199
std:: io:: Error :: new ( std:: io:: ErrorKind :: InvalidInput , msg)
205
200
} ) ?;
206
201
let dir_file = fs:: OpenOptions :: new ( ) . read ( true ) . open ( parent_directory) ?;
207
- unsafe {
208
- // The above call to `fs::remove_file` corresponds to POSIX `unlink`, whose changes
209
- // to the inode might get cached (and hence possibly lost on crash), depending on
210
- // the target platform and file system.
211
- //
212
- // In order to assert we permanently removed the file in question we therefore
213
- // call `fsync` on the parent directory on platforms that support it,
214
- libc:: fsync ( dir_file. as_raw_fd ( ) ) ;
215
- }
202
+ // The above call to `fs::remove_file` corresponds to POSIX `unlink`, whose changes
203
+ // to the inode might get cached (and hence possibly lost on crash), depending on
204
+ // the target platform and file system.
205
+ //
206
+ // In order to assert we permanently removed the file in question we therefore
207
+ // call `fsync` on the parent directory on platforms that support it,
208
+ dir_file. sync_all ( ) ?;
216
209
}
217
210
218
211
if dest_file_path. is_file ( ) {
0 commit comments