From 92da5168e150e34c62ed4aee64afbb1a46596fff Mon Sep 17 00:00:00 2001 From: Michael Eischer Date: Tue, 29 Dec 2020 15:21:16 +0100 Subject: [PATCH] ui: force backup progress update on signal --- internal/ui/backup.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/internal/ui/backup.go b/internal/ui/backup.go index 5b37446a9..254605f10 100644 --- a/internal/ui/backup.go +++ b/internal/ui/backup.go @@ -10,6 +10,7 @@ import ( "github.com/restic/restic/internal/archiver" "github.com/restic/restic/internal/restic" + "github.com/restic/restic/internal/ui/signals" "github.com/restic/restic/internal/ui/termstatus" ) @@ -87,6 +88,7 @@ func (b *Backup) Run(ctx context.Context) error { ) t := time.NewTicker(time.Second) + signalsCh := signals.GetProgressChannel() defer t.Stop() defer close(b.closed) // Reset status when finished @@ -97,6 +99,8 @@ func (b *Backup) Run(ctx context.Context) error { }() for { + forceUpdate := false + select { case <-ctx.Done(): return nil @@ -133,10 +137,12 @@ func (b *Backup) Run(ctx context.Context) error { todo := float64(total.Bytes - processed.Bytes) secondsRemaining = uint64(secs / float64(processed.Bytes) * todo) } + case <-signalsCh: + forceUpdate = true } // limit update frequency - if time.Since(lastUpdate) < b.MinUpdatePause || b.MinUpdatePause == 0 { + if !forceUpdate && (time.Since(lastUpdate) < b.MinUpdatePause || b.MinUpdatePause == 0) { continue } lastUpdate = time.Now()