diff --git a/client/status/viewmodel/render.go b/client/status/viewmodel/render.go index 114323c..c72b46e 100644 --- a/client/status/viewmodel/render.go +++ b/client/status/viewmodel/render.go @@ -374,13 +374,15 @@ func renderReplicationReport(t *stringbuilder.B, rep *report.Report, history *by eta = time.Duration((float64(expected)-float64(replicated))/float64(rate)) * time.Second } - t.Write("Progress: ") - t.DrawBar(50, replicated, expected, changeCount) - t.Write(fmt.Sprintf(" %s / %s @ %s/s", ByteCountBinaryUint(replicated), ByteCountBinaryUint(expected), ByteCountBinary(rate))) - if eta != 0 { - t.Write(fmt.Sprintf(" (%s remaining)", humanizeDuration(eta))) + if !latest.State.IsTerminal() { + t.Write("Progress: ") + t.DrawBar(50, replicated, expected, changeCount) + t.Write(fmt.Sprintf(" %s / %s @ %s/s", ByteCountBinaryUint(replicated), ByteCountBinaryUint(expected), ByteCountBinary(rate))) + if eta != 0 { + t.Write(fmt.Sprintf(" (%s remaining)", humanizeDuration(eta))) + } + t.Newline() } - t.Newline() if containsInvalidSizeEstimates { t.Write("NOTE: not all steps could be size-estimated, total estimate is likely imprecise!") t.Newline() @@ -493,15 +495,17 @@ func renderPrunerReport(t *stringbuilder.B, r *pruner.Report, fsfilter FilterFun } // global progress bar - progress := int(math.Round(80 * float64(completedDestroyCount) / float64(totalDestroyCount))) - t.Write("Progress: ") - t.Write("[") - t.Write(stringbuilder.Times("=", progress)) - t.Write(">") - t.Write(stringbuilder.Times("-", 80-progress)) - t.Write("]") - t.Printf(" %d/%d snapshots", completedDestroyCount, totalDestroyCount) - t.Newline() + if !state.IsTerminal() { + progress := int(math.Round(80 * float64(completedDestroyCount) / float64(totalDestroyCount))) + t.Write("Progress: ") + t.Write("[") + t.Write(stringbuilder.Times("=", progress)) + t.Write(">") + t.Write(stringbuilder.Times("-", 80-progress)) + t.Write("]") + t.Printf(" %d/%d snapshots", completedDestroyCount, totalDestroyCount) + t.Newline() + } sort.SliceStable(all, func(i, j int) bool { return strings.Compare(all[i].Filesystem, all[j].Filesystem) == -1 diff --git a/daemon/pruner/pruner.go b/daemon/pruner/pruner.go index a1bdb3e..e91a346 100644 --- a/daemon/pruner/pruner.go +++ b/daemon/pruner/pruner.go @@ -199,6 +199,16 @@ const ( Done ) +// Returns true in case the State is a terminal state(PlanErr, ExecErr, Done) +func (s State) IsTerminal() bool { + switch s { + case PlanErr, ExecErr, Done: + return true + default: + return false + } +} + type updater func(func(*Pruner)) func (p *Pruner) Prune() { diff --git a/replication/report/replication_report.go b/replication/report/replication_report.go index 44a981a..fcaed23 100644 --- a/replication/report/replication_report.go +++ b/replication/report/replication_report.go @@ -192,3 +192,14 @@ func (r *Report) GetFailedFilesystemsCountInLatestAttempt() int { return 0 } } + +// Returns true in case the AttemptState is a terminal +// state(AttemptPlanningError, AttemptFanOutError, AttemptDone) +func (a AttemptState) IsTerminal() bool { + switch a { + case AttemptPlanningError, AttemptFanOutError, AttemptDone: + return true + default: + return false + } +}