From d80e108b03840c58a65a223b8a5ac2dcd86de135 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Sun, 29 Apr 2018 15:01:21 +0200 Subject: [PATCH] backup: Clear status lines on finish --- internal/ui/backup.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/internal/ui/backup.go b/internal/ui/backup.go index f6f840136..71aaa5552 100644 --- a/internal/ui/backup.go +++ b/internal/ui/backup.go @@ -40,6 +40,7 @@ type Backup struct { processedCh chan counter errCh chan struct{} workerCh chan fileWorkerMessage + clearStatus chan struct{} summary struct { sync.Mutex @@ -68,6 +69,7 @@ func NewBackup(term *termstatus.Terminal, verbosity uint) *Backup { processedCh: make(chan counter), errCh: make(chan struct{}), workerCh: make(chan fileWorkerMessage), + clearStatus: make(chan struct{}), } } @@ -90,6 +92,9 @@ func (b *Backup) Run(ctx context.Context) error { select { case <-ctx.Done(): return nil + case <-b.clearStatus: + started = false + b.term.SetStatus([]string{""}) case t, ok := <-b.totalCh: if ok { total = t @@ -332,6 +337,8 @@ func (b *Backup) ReportTotal(item string, s archiver.ScanStats) { // Finish prints the finishing messages. func (b *Backup) Finish() { + b.clearStatus <- struct{}{} + b.V("processed %s in %s", formatBytes(b.totalBytes), formatDuration(time.Since(b.start))) b.V("\n") b.V("Files: %5d new, %5d changed, %5d unmodified\n", b.summary.Files.New, b.summary.Files.Changed, b.summary.Files.Unchanged)