mirror of
https://github.com/rclone/rclone.git
synced 2025-06-05 03:34:35 +08:00
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:
@ -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
|
||||
|
Reference in New Issue
Block a user