File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -104,11 +104,17 @@ impl KVStoreUnpersister for FilesystemPersister {
104
104
}
105
105
106
106
fs:: remove_file ( & dest_file) ?;
107
- let parent_directory = dest_file. parent ( ) . unwrap ( ) ;
108
- let dir_file = fs:: OpenOptions :: new ( ) . read ( true ) . open ( parent_directory) ?;
109
107
#[ cfg( not( target_os = "windows" ) ) ]
110
108
{
109
+ let parent_directory = dest_file. parent ( ) . unwrap ( ) ;
110
+ let dir_file = fs:: OpenOptions :: new ( ) . read ( true ) . open ( parent_directory) ?;
111
111
unsafe {
112
+ // The above call to `fs::remove_file` corresponds to POSIX `unlink`, whose changes
113
+ // to the inode might get cached (and hence possibly lost on crash), depending on
114
+ // the target platform and file system.
115
+ //
116
+ // In order to assert we permanently removed the file in question we therefore
117
+ // call `fsync` on the parent directory on platforms that support it,
112
118
libc:: fsync ( dir_file. as_raw_fd ( ) ) ;
113
119
}
114
120
}
You can’t perform that action at this time.
0 commit comments