Skip to content
This repository was archived by the owner on Sep 9, 2020. It is now read-only.

Commit e241dcf

Browse files
authored
Merge pull request #655 from ibrasho-forks/update-error
internal/fs: update error message when rename fallback fails
2 parents 9a203ea + e6b1a5f commit e241dcf

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

internal/fs/fs.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,18 @@ func renameByCopy(src, dst string) error {
100100
var cerr error
101101
if dir, _ := IsDir(src); dir {
102102
cerr = CopyDir(src, dst)
103+
if cerr != nil {
104+
cerr = errors.Wrap(cerr, "copying directory failed")
105+
}
103106
} else {
104107
cerr = copyFile(src, dst)
108+
if cerr != nil {
109+
cerr = errors.Wrap(cerr, "copying file failed")
110+
}
105111
}
106112

107113
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)
109115
}
110116

111117
return errors.Wrapf(os.RemoveAll(src), "cannot delete %s", src)
@@ -222,13 +228,13 @@ func CopyDir(src, dst string) error {
222228

223229
if entry.IsDir() {
224230
if err = CopyDir(srcPath, dstPath); err != nil {
225-
return err
231+
return errors.Wrap(err, "copying directory failed")
226232
}
227233
} else {
228234
// This will include symlinks, which is what we want when
229235
// copying things.
230236
if err = copyFile(srcPath, dstPath); err != nil {
231-
return err
237+
return errors.Wrap(err, "copying file failed")
232238
}
233239
}
234240
}

0 commit comments

Comments
 (0)