Skip to content

Commit ce6701f

Browse files
committed
status: fix over-counted step when status != stepping
This is a fixup of commit b00b61e Author: Christian Schwarz <[email protected]> Date: Sun Nov 21 15:15:23 2021 +0100 status: user-visible replication step number should start at 1 fixes #589 refs #538
1 parent 0121929 commit ce6701f

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

client/status/viewmodel/render.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,16 @@ func printFilesystemStatus(t *stringbuilder.B, rep *report.FilesystemReport, max
228228
}
229229

230230
userVisisbleCurrentStep, userVisibleTotalSteps := rep.CurrentStep, len(rep.Steps)
231-
if len(rep.Steps) > 0 {
232-
userVisisbleCurrentStep = rep.CurrentStep + 1 // CurrentStep is an index that starts at 0
231+
// `.CurrentStep` is == len(rep.Steps) if all steps are done.
232+
// Until then, it's an index into .Steps that starts at 0.
233+
// For the user, we want it to start at 1.
234+
if rep.CurrentStep >= len(rep.Steps) {
235+
// rep.CurrentStep is what we want to show.
236+
// We check for >= and not == for robustness.
237+
} else {
238+
// We're not done yet, so, make step count start at 1
239+
// (The `.State` is included in the output, indicating we're not done yet)
240+
userVisisbleCurrentStep = rep.CurrentStep + 1
233241
}
234242
status := fmt.Sprintf("%s (step %d/%d, %s/%s)%s",
235243
strings.ToUpper(string(rep.State)),

0 commit comments

Comments
 (0)