Skip to content

Commit 61b4283

Browse files
authored
feat(windows): add a feature to immediate tempfile deletion (#340)
This adds a feature making it possible to disable the immediate deletion of unnamed temporary files on windows (introduced in 461369f). Hopefully, this will fix #339. If so, I'll revert 461369f entirely.
1 parent c2d16b3 commit 61b4283

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,6 @@ doc-comment = "0.3"
4040
[features]
4141
default = ["getrandom"]
4242
nightly = []
43+
# Disables immediate deletion of newly opened tempfiles on windows, instead relying on the old
44+
# "delete on close" behavior. This will hopefully fix #339.
45+
unstable-windows-keep-open-tempfile = []

src/file/imp/windows.rs

+1
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ pub fn create(dir: &Path) -> io::Result<File> {
7676
.open(path)?;
7777
// Attempt to delete the file by-handle. If this fails, do nothing; the file will be
7878
// deleted on close anyways.
79+
#[cfg(not(feature = "unstable-windows-keep-open-tempfile"))]
7980
let _ = delete_open_file(&f);
8081
Ok(f)
8182
},

0 commit comments

Comments
 (0)