Skip to content

Commit 65b85d4

Browse files
Copilotsourcefrog
andcommitted
Give up on reflinks after any error to handle Windows behavior
Co-authored-by: sourcefrog <346355+sourcefrog@users.noreply.github.com>
1 parent d6b24e2 commit 65b85d4

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

src/copy_tree.rs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
//! Copy a source tree, with some exclusions, to a new temporary directory.
44
55
use std::fs;
6-
use std::io::ErrorKind;
76
use std::path::Path;
87
use std::sync::atomic::{AtomicBool, Ordering};
98

@@ -41,17 +40,10 @@ fn copy_file(src: &Path, dest: &Path, reflink_supported: &AtomicBool) -> Result<
4140
return Ok(metadata.len());
4241
}
4342
Err(e) => {
44-
// Check if this is a "not supported" error
45-
if e.kind() == ErrorKind::Unsupported {
46-
// Mark reflink as not supported so we don't try again
47-
reflink_supported.store(false, Ordering::Relaxed);
48-
debug!(
49-
"Reflinks not supported on this filesystem, falling back to regular copy"
50-
);
51-
} else {
52-
// Log other errors
53-
debug!("Reflink failed: {}, falling back to regular copy", e);
54-
}
43+
// On Windows, reflink can fail without returning ErrorKind::Unsupported,
44+
// so we give up on reflinks after any error to avoid repeated failures.
45+
reflink_supported.store(false, Ordering::Relaxed);
46+
debug!("Reflink failed: {}, falling back to regular copy", e);
5547
}
5648
}
5749
}

0 commit comments

Comments
 (0)