cmd: Fix -P not ending with a new line
Before this fix rclone didn't wait for the stats to be finished before exiting, so the final new line was never printed. After this change rclone will wait for the stats routine to cease before exiting.
This commit is contained in:
parent
d9037fe2be
commit
06ae4258be
3 changed files with 37 additions and 26 deletions
|
@ -25,8 +25,8 @@ const (
|
|||
|
||||
// startProgress starts the progress bar printing
|
||||
//
|
||||
// It returns a channel which should be closed to stop the stats.
|
||||
func startProgress() chan struct{} {
|
||||
// It returns a func which should be called to stop the stats.
|
||||
func startProgress() func() {
|
||||
stopStats := make(chan struct{})
|
||||
oldLogPrint := fs.LogPrint
|
||||
if !log.Redirected() {
|
||||
|
@ -36,7 +36,10 @@ func startProgress() chan struct{} {
|
|||
|
||||
}
|
||||
}
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
progressInterval := defaultProgressInterval
|
||||
if ShowStats() && *statsInterval > 0 {
|
||||
progressInterval = *statsInterval
|
||||
|
@ -54,7 +57,10 @@ func startProgress() chan struct{} {
|
|||
}
|
||||
}
|
||||
}()
|
||||
return stopStats
|
||||
return func() {
|
||||
close(stopStats)
|
||||
wg.Wait()
|
||||
}
|
||||
}
|
||||
|
||||
// VT100 codes
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue