Stops removing target bucket content when url.Error (#2377)

This commit is contained in:
ebozduman
2018-02-21 12:22:09 +05:30
committed by Nitish Tiwari
parent 97c7984bca
commit efeaf2ee72
2 changed files with 31 additions and 20 deletions
+26 -15
View File
@@ -460,11 +460,7 @@ func (mj *mirrorJob) startMirror(ctx context.Context, cancelMirror context.Cance
return
}
if sURLs.Error != nil {
if strings.Contains(sURLs.Error.ToGoError().Error(), " is a folder.") {
mj.status.errorIf(sURLs.Error.Trace(), "Folder cannot be copied. Please use `...` suffix.")
} else {
mj.status.errorIf(sURLs.Error.Trace(), "Unable to prepare URL for copying.")
}
errCh <- sURLs.Error
continue
}
@@ -526,20 +522,35 @@ func (mj *mirrorJob) mirror(ctx context.Context, cancelMirror context.CancelFunc
// Start mirroring.
go mj.startMirror(ctx, cancelMirror, mirrorErrCh)
if err := <-mirrorErrCh; err != nil {
return err.Trace()
}
// Wait until all progress bar updates are actually shown and quit.
defer mj.stopStatus()
if mj.isWatch {
if err := <-watchErrCh; err != nil {
var err *probe.Error
var ok bool
for {
select {
case err, ok = <-mirrorErrCh:
if !ok || err == nil {
if mj.isWatch {
continue
}
return nil
}
case err, ok = <-watchErrCh:
if !ok || err == nil {
return nil
}
}
if err != nil {
switch err.ToGoError().(type) {
case BrokenSymlink, TooManyLevelsSymlink, PathNotFound,
PathInsufficientPermission, ObjectOnGlacier:
continue
}
return err.Trace()
}
}
// Wait until all progress bar updates are actually shown and quit.
mj.stopStatus()
return nil
}
func newMirrorJob(srcURL, dstURL string, isFake, isRemove, isOverwrite, isWatch bool, excludeOptions []string, olderThan, newerThan int) *mirrorJob {
+5 -5
View File
@@ -64,9 +64,9 @@ func checkMirrorSyntax(ctx *cli.Context) {
fatalIf(errInvalidArgument().Trace(), "Invalid target arguments to mirror command.")
}
url := newClientURL(tgtURL)
if url.Host != "" {
if url.Path == string(url.Separator) {
clientURL := newClientURL(tgtURL)
if clientURL.Host != "" {
if clientURL.Path == string(clientURL.Separator) {
fatalIf(errInvalidArgument().Trace(tgtURL),
fmt.Sprintf("Target `%s` does not contain bucket name.", tgtURL))
}
@@ -114,8 +114,8 @@ func deltaSourceTarget(sourceURL, targetURL string, isFake, isOverwrite, isRemov
// List both source and target, compare and return values through channel.
for diffMsg := range objectDifference(sourceClnt, targetClnt, sourceURL, targetURL) {
if diffMsg.Error != nil {
errorIf(diffMsg.Error, "Unable to mirror objects.")
// Ignore error and proceed to next object.
// Send all errors through the channel
URLsCh <- URLs{Error: diffMsg.Error}
continue
}