forked from TrueCloudLab/restic
backup: Clear status lines on finish
This commit is contained in:
parent
846c2b6869
commit
d80e108b03
1 changed files with 7 additions and 0 deletions
|
@ -40,6 +40,7 @@ type Backup struct {
|
||||||
processedCh chan counter
|
processedCh chan counter
|
||||||
errCh chan struct{}
|
errCh chan struct{}
|
||||||
workerCh chan fileWorkerMessage
|
workerCh chan fileWorkerMessage
|
||||||
|
clearStatus chan struct{}
|
||||||
|
|
||||||
summary struct {
|
summary struct {
|
||||||
sync.Mutex
|
sync.Mutex
|
||||||
|
@ -68,6 +69,7 @@ func NewBackup(term *termstatus.Terminal, verbosity uint) *Backup {
|
||||||
processedCh: make(chan counter),
|
processedCh: make(chan counter),
|
||||||
errCh: make(chan struct{}),
|
errCh: make(chan struct{}),
|
||||||
workerCh: make(chan fileWorkerMessage),
|
workerCh: make(chan fileWorkerMessage),
|
||||||
|
clearStatus: make(chan struct{}),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,6 +92,9 @@ func (b *Backup) Run(ctx context.Context) error {
|
||||||
select {
|
select {
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
return nil
|
return nil
|
||||||
|
case <-b.clearStatus:
|
||||||
|
started = false
|
||||||
|
b.term.SetStatus([]string{""})
|
||||||
case t, ok := <-b.totalCh:
|
case t, ok := <-b.totalCh:
|
||||||
if ok {
|
if ok {
|
||||||
total = t
|
total = t
|
||||||
|
@ -332,6 +337,8 @@ func (b *Backup) ReportTotal(item string, s archiver.ScanStats) {
|
||||||
|
|
||||||
// Finish prints the finishing messages.
|
// Finish prints the finishing messages.
|
||||||
func (b *Backup) Finish() {
|
func (b *Backup) Finish() {
|
||||||
|
b.clearStatus <- struct{}{}
|
||||||
|
|
||||||
b.V("processed %s in %s", formatBytes(b.totalBytes), formatDuration(time.Since(b.start)))
|
b.V("processed %s in %s", formatBytes(b.totalBytes), formatDuration(time.Since(b.start)))
|
||||||
b.V("\n")
|
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)
|
b.V("Files: %5d new, %5d changed, %5d unmodified\n", b.summary.Files.New, b.summary.Files.Changed, b.summary.Files.Unchanged)
|
||||||
|
|
Loading…
Reference in a new issue