This repository was archived by the owner on Sep 9, 2020. It is now read-only.
File tree 1 file changed +9
-3
lines changed 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -100,12 +100,18 @@ func renameByCopy(src, dst string) error {
100
100
var cerr error
101
101
if dir , _ := IsDir (src ); dir {
102
102
cerr = CopyDir (src , dst )
103
+ if cerr != nil {
104
+ cerr = errors .Wrap (cerr , "copying directory failed" )
105
+ }
103
106
} else {
104
107
cerr = copyFile (src , dst )
108
+ if cerr != nil {
109
+ cerr = errors .Wrap (cerr , "copying file failed" )
110
+ }
105
111
}
106
112
107
113
if cerr != nil {
108
- return errors .Wrapf (cerr , "second attempt failed: cannot rename %s to %s" , src , dst )
114
+ return errors .Wrapf (cerr , "rename fallback failed: cannot rename %s to %s" , src , dst )
109
115
}
110
116
111
117
return errors .Wrapf (os .RemoveAll (src ), "cannot delete %s" , src )
@@ -222,13 +228,13 @@ func CopyDir(src, dst string) error {
222
228
223
229
if entry .IsDir () {
224
230
if err = CopyDir (srcPath , dstPath ); err != nil {
225
- return err
231
+ return errors . Wrap ( err , "copying directory failed" )
226
232
}
227
233
} else {
228
234
// This will include symlinks, which is what we want when
229
235
// copying things.
230
236
if err = copyFile (srcPath , dstPath ); err != nil {
231
- return err
237
+ return errors . Wrap ( err , "copying file failed" )
232
238
}
233
239
}
234
240
}
You can’t perform that action at this time.
0 commit comments