Set exitcode on copy/mirror source failure (#4798)

Also fixes errors potentially being swallowed by filtering.

Fixes #4773

```
λ go build&&mc cp s3/default/1.mp4 1.mp4
mc: <ERROR> Unable to prepare URL for copying. Unable to guess the type of copy operation.

λ echo %errorlevel%
1

λ _
```
This commit is contained in:
Klaus Post
2023-12-19 23:14:22 -08:00
committed by GitHub
parent 60286667cc
commit 31ec9b6a3b
2 changed files with 9 additions and 0 deletions
+5
View File
@@ -659,6 +659,11 @@ loop:
}
}
// Source has error
if errSeen && totalObjects == 0 && retErr == nil {
retErr = exitStatus(globalErrorExitStatus)
}
return retErr
}
+4
View File
@@ -361,6 +361,10 @@ func prepareCopyURLs(ctx context.Context, o prepareCopyURLsOpts) chan URLs {
go func() {
defer close(finalCopyURLsCh)
for cpURLs := range copyURLsCh {
if cpURLs.Error != nil {
finalCopyURLsCh <- cpURLs
continue
}
// Skip objects older than --older-than parameter if specified
if o.olderThan != "" && isOlder(cpURLs.SourceContent.Time, o.olderThan) {
continue