Skip to content

Commit 75c5d31

Browse files
committed
Disable atomic replace APIs on Windows
Until we can debug what the issue might be. It looks to me like the `tempfile` crate has special logic here https://github.com/Stebalien/tempfile/blob/0657fdf24925287e6d5544d9e321a48d7ceaafdc/src/file/imp/windows.rs#L92 But we're just relying on cap-std, and we need to dig to see if there's something similar or it needs changes.
1 parent c28d722 commit 75c5d31

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

src/dirext.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ pub trait CapStdExtDirExt {
199199
/// ```
200200
///
201201
/// Any existing file will be replaced.
202+
#[cfg(not(windows))]
202203
fn atomic_replace_with<F, T, E>(
203204
&self,
204205
destname: impl AsRef<Path>,
@@ -209,9 +210,11 @@ pub trait CapStdExtDirExt {
209210
E: From<std::io::Error>;
210211

211212
/// Atomically write the provided contents to a file.
213+
#[cfg(not(windows))]
212214
fn atomic_write(&self, destname: impl AsRef<Path>, contents: impl AsRef<[u8]>) -> Result<()>;
213215

214216
/// Atomically write the provided contents to a file, using specified permissions.
217+
#[cfg(not(windows))]
215218
fn atomic_write_with_perms(
216219
&self,
217220
destname: impl AsRef<Path>,
@@ -716,6 +719,7 @@ impl CapStdExtDirExt for Dir {
716719
Ok(())
717720
}
718721

722+
#[cfg(not(windows))]
719723
fn atomic_replace_with<F, T, E>(
720724
&self,
721725
destname: impl AsRef<Path>,
@@ -753,10 +757,12 @@ impl CapStdExtDirExt for Dir {
753757
Ok(r)
754758
}
755759

760+
#[cfg(not(windows))]
756761
fn atomic_write(&self, destname: impl AsRef<Path>, contents: impl AsRef<[u8]>) -> Result<()> {
757762
self.atomic_replace_with(destname, |f| f.write_all(contents.as_ref()))
758763
}
759764

765+
#[cfg(not(windows))]
760766
fn atomic_write_with_perms(
761767
&self,
762768
destname: impl AsRef<Path>,

tests/it/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ fn default_mode(d: &Dir) -> Result<Permissions> {
175175
}
176176

177177
#[test]
178+
#[cfg(not(windows))]
178179
fn link_tempfile_with() -> Result<()> {
179180
let td = cap_tempfile::tempdir(cap_std::ambient_authority())?;
180181
let p = Path::new("foo");

0 commit comments

Comments
 (0)