Skip to content

Commit

Permalink
mirror: Quit after showing all progressbar updates (#2020)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
vadmeste authored and harshavardhana committed Feb 17, 2017
1 parent e7e44b9 commit 7483cde
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions cmd/mirror-main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {

Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 7483cde

Please sign in to comment.