mirror of
https://github.com/restic/restic.git
synced 2025-11-15 12:03:09 +00:00
ui: update status for the backup command on non-interactive terminals
Allow the backup command to print status on non-interactive terminals. The output is disabled by setting a MinUpdatePause == 0.
This commit is contained in:
@@ -90,7 +90,11 @@ func (b *Backup) Run(ctx context.Context) error {
|
||||
defer t.Stop()
|
||||
defer close(b.closed)
|
||||
// Reset status when finished
|
||||
defer b.term.SetStatus([]string{""})
|
||||
defer func() {
|
||||
if b.term.CanUpdateStatus() {
|
||||
b.term.SetStatus([]string{""})
|
||||
}
|
||||
}()
|
||||
|
||||
for {
|
||||
select {
|
||||
@@ -132,7 +136,7 @@ func (b *Backup) Run(ctx context.Context) error {
|
||||
}
|
||||
|
||||
// limit update frequency
|
||||
if time.Since(lastUpdate) < b.MinUpdatePause {
|
||||
if time.Since(lastUpdate) < b.MinUpdatePause || b.MinUpdatePause == 0 {
|
||||
continue
|
||||
}
|
||||
lastUpdate = time.Now()
|
||||
|
||||
Reference in New Issue
Block a user