From 319b3d84342bb157a9891d6e732d0df98160212f Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Wed, 27 Apr 2016 20:37:38 -0700 Subject: [PATCH] mirror/cp: Skip NoSuckKey, NoSuchBucket errors properly in cp/mirror. Fixes #1693 --- client-s3.go | 13 +++++++++++++ cp-main.go | 15 +++------------ 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/client-s3.go b/client-s3.go index 305dbd34..65400186 100644 --- a/client-s3.go +++ b/client-s3.go @@ -148,6 +148,19 @@ func (c *s3Client) Get() (io.Reader, *probe.Error) { if errResponse.Code == "AccessDenied" { return nil, probe.NewError(PathInsufficientPermission{Path: c.targetURL.String()}) } + if errResponse.Code == "NoSuchBucket" { + return nil, probe.NewError(BucketDoesNotExist{ + Bucket: bucket, + }) + } + if errResponse.Code == "InvalidBucketName" { + return nil, probe.NewError(BucketInvalid{ + Bucket: bucket, + }) + } + if errResponse.Code == "NoSuchKey" || errResponse.Code == "InvalidArgument" { + return nil, probe.NewError(ObjectMissing{}) + } return nil, probe.NewError(e) } return reader, nil diff --git a/cp-main.go b/cp-main.go index 7378ac97..cf867c14 100644 --- a/cp-main.go +++ b/cp-main.go @@ -348,19 +348,10 @@ func doCopySession(session *sessionV7) { // For all non critical errors we can continue for the // remaining files. switch cpURLs.Error.ToGoError().(type) { - // Handle this specifically for filesystem related - // errors. - case BrokenSymlink: + // Handle this specifically for filesystem related errors. + case BrokenSymlink, TooManyLevelsSymlink, PathNotFound, PathInsufficientPermission: continue - case TooManyLevelsSymlink: - continue - case PathNotFound: - continue - case PathInsufficientPermission: - continue - case ObjectAlreadyExists: - continue - case BucketDoesNotExist: + case BucketNameEmpty, ObjectMissing, ObjectAlreadyExists, BucketDoesNotExist, BucketInvalid: continue } // For critical errors we should exit. Session