From 6d1a41458bdb1eda4d7064af16dcf4692e2967bb Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Fri, 3 Jan 2020 12:14:39 -0800 Subject: [PATCH] Use colorjson to indent json properly in cp (#3030) Additionally also do not initialize progress bar in json or quiet mode in mirror. Fixes #3029 Fixes #3017 --- cmd/cp-main.go | 2 +- cmd/difference.go | 8 ++++++++ cmd/mirror-main.go | 8 ++++---- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/cmd/cp-main.go b/cmd/cp-main.go index b9019a2c..06745dc8 100644 --- a/cmd/cp-main.go +++ b/cmd/cp-main.go @@ -19,7 +19,6 @@ package cmd import ( "bufio" "context" - "encoding/json" "errors" "fmt" "io" @@ -30,6 +29,7 @@ import ( "github.com/fatih/color" "github.com/minio/cli" + json "github.com/minio/mc/pkg/colorjson" "github.com/minio/mc/pkg/probe" "github.com/minio/minio/pkg/console" ) diff --git a/cmd/difference.go b/cmd/difference.go index a2fd0199..4108d8bc 100644 --- a/cmd/difference.go +++ b/cmd/difference.go @@ -284,6 +284,14 @@ func difference(sourceClnt, targetClnt Client, sourceURL, targetURL string, isMe err := differenceInternal(sourceClnt, targetClnt, sourceURL, targetURL, isMetadata, isRecursive, returnSimilar, dirOpt, diffCh) if err != nil { + // handle this specifically for filesystem related errors. + switch err.ToGoError().(type) { + case BrokenSymlink, TooManyLevelsSymlink, PathNotFound, PathInsufficientPermission: + diffCh <- diffMessage{ + Error: err, + } + return + } errorIf(err, "Unable to list comparison retrying..") } else { // Success. diff --git a/cmd/mirror-main.go b/cmd/mirror-main.go index 69d75ad1..c7b5d08e 100644 --- a/cmd/mirror-main.go +++ b/cmd/mirror-main.go @@ -695,13 +695,13 @@ func newMirrorJob(srcURL, dstURL string, isFake, isRemove, isOverwrite, isWatch, // we'll define the status to use here, // do we want the quiet status? or the progressbar - var status = NewProgressStatus(mj.parallel) if globalQuiet { - status = NewQuietStatus(mj.parallel) + mj.status = NewQuietStatus(mj.parallel) } else if globalJSON { - status = NewQuietStatus(mj.parallel) + mj.status = NewQuietStatus(mj.parallel) + } else { + mj.status = NewProgressStatus(mj.parallel) } - mj.status = status return &mj }