2
2
mirror of https://github.com/octoleo/restic.git synced 2024-11-22 21:05:10 +00:00

backup: Clear status lines on finish

This commit is contained in:
Alexander Neumann 2018-04-29 15:01:21 +02:00
parent 846c2b6869
commit d80e108b03

View File

@ -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)