fix: preserve successfully copied files with timestamp failure (#2519)

* fix: preserve successfully copied files with timestamp failure

* improve error message
This commit is contained in:
valoq authored and GitHub committed 2026-04-13 22:41:44 +02:00
1 parent 1c069f480a
commit b14d2fb598
1 file changed
+1 -5
+1 -5
View File
@@ -94,10 +94,6 @@ func copyFile(src, dst string, preserve []string, info os.FileInfo, nums chan<-
mtime := info.ModTime() mtime := info.ModTime()
if err := os.Chtimes(dst, atime, mtime); err != nil { if err := os.Chtimes(dst, atime, mtime); err != nil {
errs <- err errs <- err
if err = os.Remove(dst); err != nil {
errs <- err
}
return
} }
} }
} }
@@ -175,7 +171,7 @@ func copyAll(srcs []string, dstDir string, preserve []string) (nums chan int64,
atime := times.Get(info).AccessTime() atime := times.Get(info).AccessTime()
mtime := info.ModTime() mtime := info.ModTime()
if err := os.Chtimes(path, atime, mtime); err != nil { if err := os.Chtimes(path, atime, mtime); err != nil {
errs <- fmt.Errorf("chtimes: %w", err) errs <- err
} }
} }