Skip to content

Commit 08043cc

Browse files
committed
fix Access denied issue on windows
1 parent b835d2e commit 08043cc

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/file_store.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -200,13 +200,14 @@ impl FileStore {
200200
.open(&tmp_filename)?;
201201
file.lock_exclusive()?;
202202
tmp_file.lock_exclusive()?;
203-
204203
match Write::write_all(&mut tmp_file, json_string.as_bytes()) {
205204
Err(err) => Err(err),
206205
Ok(_) => {
207-
rename(tmp_filename, file_name)?;
208206
tmp_file.unlock()?;
209-
file.unlock()
207+
file.unlock()?;
208+
drop(file);
209+
drop(tmp_file);
210+
rename(tmp_filename, file_name)
210211
}
211212
}
212213
}

0 commit comments

Comments
 (0)