22
33//! Copy a source tree, with some exclusions, to a new temporary directory.
44
5+ use std:: fs;
6+ use std:: io:: ErrorKind ;
7+ use std:: path:: Path ;
58use std:: sync:: atomic:: { AtomicBool , Ordering } ;
69
710use anyhow:: Context ;
@@ -27,30 +30,32 @@ static VCS_DIRS: &[&str] = &[".git", ".hg", ".bzr", ".svn", "_darcs", ".jj", ".p
2730
2831/// Copy a file, attempting to use reflink if supported.
2932/// Returns the number of bytes copied.
30- fn copy_file ( src : & std :: path :: Path , dest : & std :: path :: Path , reflink_supported : & AtomicBool ) -> anyhow:: Result < u64 > {
33+ fn copy_file ( src : & Path , dest : & Path , reflink_supported : & AtomicBool ) -> anyhow:: Result < u64 > {
3134 // Try reflink first if we haven't determined it's not supported
3235 if reflink_supported. load ( Ordering :: Relaxed ) {
3336 match reflink:: reflink ( src, dest) {
3437 Ok ( ( ) ) => {
3538 // Reflink succeeded, get file size for progress tracking
36- let metadata = std :: fs:: metadata ( dest)
39+ let metadata = fs:: metadata ( dest)
3740 . with_context ( || format ! ( "Failed to get metadata for {}" , dest. display( ) ) ) ?;
3841 return Ok ( metadata. len ( ) ) ;
3942 }
4043 Err ( e) => {
4144 // Check if this is a "not supported" error
42- if e. kind ( ) == std :: io :: ErrorKind :: Unsupported {
45+ if e. kind ( ) == ErrorKind :: Unsupported {
4346 // Mark reflink as not supported so we don't try again
4447 reflink_supported. store ( false , Ordering :: Relaxed ) ;
4548 debug ! ( "Reflinks not supported on this filesystem, falling back to regular copy" ) ;
49+ } else {
50+ // Log other errors
51+ warn ! ( "Reflink failed: {}, falling back to regular copy" , e) ;
4652 }
47- // For other errors, also fall back to regular copy
4853 }
4954 }
5055 }
5156
5257 // Fall back to regular copy
53- std :: fs:: copy ( src, dest)
58+ fs:: copy ( src, dest)
5459 . with_context ( || format ! ( "Failed to copy {} to {}" , src. display( ) , dest. display( ) ) )
5560}
5661
0 commit comments