From 744b4728d1682bfaa7beac6b39e14d298f69ddcf Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Mon, 1 Feb 2016 13:34:06 -0800 Subject: [PATCH] progressBar: Finish progress bar if total is greater than 0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In case of 'mc mirror' => mc prints an erroneous progress bar with 0bytes. ``` mc mirror /usr/local/Cellar/go/1.5.3/libexec play/test123/libexec 0 B / ? ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▓ 0.00 % 0 ``` This patch fixes #1592 --- cp-main.go | 7 ++++--- mirror-main.go | 4 +++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/cp-main.go b/cp-main.go index 743d4dba..2680213d 100644 --- a/cp-main.go +++ b/cp-main.go @@ -356,9 +356,10 @@ func doCopySession(session *sessionV6) { wg.Wait() if !globalQuiet && !globalJSON { - progressReader.ProgressBar.Finish() - } - if globalQuiet { + if progressReader.ProgressBar.Total > 0 { + progressReader.ProgressBar.Finish() + } + } else { accntStat := accntReader.Stat() cpStatMessage := copyStatMessage{ Total: accntStat.Total, diff --git a/mirror-main.go b/mirror-main.go index d75c15d6..690a2a2d 100644 --- a/mirror-main.go +++ b/mirror-main.go @@ -339,7 +339,9 @@ func doMirrorSession(session *sessionV6) { wg.Wait() if !globalQuiet && !globalJSON { - progressReader.ProgressBar.Finish() + if progressReader.ProgressBar.Total > 0 { + progressReader.ProgressBar.Finish() + } } else { accntStat := accntReader.Stat() mrStatMessage := mirrorStatMessage{