@@ -28,9 +28,16 @@ pub fn copy<P: AsRef<Path>, Q: AsRef<Path>>(from: P, to: Q) -> Result<u64> {
28
28
} else {
29
29
let amt = fs:: copy ( & from, & to) . with_context ( || {
30
30
format ! (
31
- "failed to copy '{}' to '{}'" ,
31
+ "failed to copy '{}' ({}) to '{}' ({}, parent {}) " ,
32
32
from. as_ref( ) . display( ) ,
33
- to. as_ref( ) . display( )
33
+ if from. as_ref( ) . exists( ) { "exists" } else { "doesn't exist" } ,
34
+ to. as_ref( ) . display( ) ,
35
+ if to. as_ref( ) . exists( ) { "exists" } else { "doesn't exist" } ,
36
+ if to. as_ref( ) . parent( ) . unwrap_or_else( || Path :: new( "" ) ) . exists( ) {
37
+ "exists"
38
+ } else {
39
+ "doesn't exist"
40
+ } ,
34
41
)
35
42
} ) ?;
36
43
Ok ( amt)
@@ -97,7 +104,20 @@ pub fn remove_file<P: AsRef<Path>>(path: P) -> Result<()> {
97
104
/// Copies the `src` directory recursively to `dst`. Both are assumed to exist
98
105
/// when this function is called.
99
106
pub fn copy_recursive ( src : & Path , dst : & Path ) -> Result < ( ) > {
100
- copy_with_callback ( src, dst, |_, _| Ok ( ( ) ) )
107
+ copy_with_callback ( src, dst, |_, _| Ok ( ( ) ) ) . with_context ( || {
108
+ format ! (
109
+ "failed to recursively copy '{}' ({}) to '{}' ({}, parent {})" ,
110
+ src. display( ) ,
111
+ if src. exists( ) { "exists" } else { "doesn't exist" } ,
112
+ dst. display( ) ,
113
+ if dst. exists( ) { "exists" } else { "doesn't exist" } ,
114
+ if dst. parent( ) . unwrap_or_else( || Path :: new( "" ) ) . exists( ) {
115
+ "exists"
116
+ } else {
117
+ "doesn't exist"
118
+ } ,
119
+ )
120
+ } )
101
121
}
102
122
103
123
/// Copies the `src` directory recursively to `dst`. Both are assumed to exist
0 commit comments