We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 836bcf2 commit 8b855f0Copy full SHA for 8b855f0
1 file changed
src/config.rs
@@ -161,7 +161,8 @@ impl State {
161
}
162
163
pub async fn async_save(&self, path: impl AsRef<Path>) -> Result<(), Error> {
164
- let path_tmp = path.as_ref().with_extension("tmp");
+ let path = path.as_ref();
165
+ let path_tmp = path.with_extension("tmp");
166
let mut fpb = tokio::fs::OpenOptions::new();
167
let fpb = fpb.create(true).write(true).truncate(true);
168
let mut fp = fpb.open(&path_tmp).await?;
@@ -170,6 +171,8 @@ impl State {
170
171
fp.sync_data().await?;
172
mem::drop(fp);
173
tokio::fs::rename(path_tmp, path).await?;
174
+ let dir = tokio::fs::File::open(path.parent().unwrap_or_else(|| Path::new("."))).await?;
175
+ dir.sync_all().await?;
176
Ok(())
177
178
0 commit comments