From 7483cdebfb7c46410819a71997288a8a84fd2398 Mon Sep 17 00:00:00 2001 From: Anis Elleuch Date: Fri, 17 Feb 2017 21:10:01 +0100 Subject: [PATCH] mirror: Quit after showing all progressbar updates (#2020) mc can quit when mirror terminates but progress bar is not able to show all made progress. This commit makes mc waits until all updates are sent to the status channel. --- cmd/mirror-main.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/cmd/mirror-main.go b/cmd/mirror-main.go index c29d3719..4c40c9be 100644 --- a/cmd/mirror-main.go +++ b/cmd/mirror-main.go @@ -272,6 +272,12 @@ func (mj *mirrorJob) startStatus() { }() } +// Stop status go routine, further updates could lead to a crash +func (mj *mirrorJob) stopStatus() { + close(mj.statusCh) + mj.wgStatus.Wait() +} + // this goroutine will watch for notifications, and add modified objects to the queue func (mj *mirrorJob) watchMirror() { @@ -484,6 +490,9 @@ func (mj *mirrorJob) mirror() { if mj.isWatch { <-mj.trapCh } + + // Wait until all progress bar updates are actually shown and quit. + mj.stopStatus() } func newMirrorJob(srcURL, dstURL string, isFake, isRemove, isWatch, isForce bool) *mirrorJob {