v0.147.2 — 4c follow-up 2: when NO counter can move, say what is being worked on
The v0.147.1 file-count fallback fixed the incremental case but not the one the demo box actually hits. Watching a second real run: bookstack reported clean byte progress (100%, 154.0 MB, 7/7 files — the byte path works), while immich sat at files_done 1 of 46, bytes_done 0, for 42 seconds. restic 0.14 only counts a file into bytes_done/files_done when it COMPLETES, so an app dominated by a single large archive (immich's ~430MB volume tar) freezes both counters. No percentage can move in that window, so stop trying to fake one. restic keeps reporting current_files and seconds_elapsed throughout. The card now names the file being processed and the elapsed time: "1 / 46 fájl (430.2 MB) · feldolgozás alatt: immich_upload.tar · 42 mp". "Working on this file for 42 seconds" is a completely different message from "0%", and it is the honest one. The last known current_files value persists across ticks that omit it (restic does not send it every tick, and blanking the label every other second is its own flicker); switching app clears it so one app's file is never shown against another. Both pinned by tests, with the real 42-second status line shape. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Nn3VgQk9iwEGgyx6QJ2NvE
This commit is contained in:
@@ -230,6 +230,50 @@ func TestParseResticStatusIncrementalRun(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestParseResticStatusKeepsCurrentFileAndElapsed — the case where NO counter can move: restic 0.14
|
||||
// only counts a file when it completes, so an app dominated by one big archive freezes bytes_done
|
||||
// AND files_done. Measured on the demo box: immich at 1 of 46 files, 0 bytes, for 42 seconds while
|
||||
// restic worked through a single ~430MB volume tar. current_files + seconds_elapsed are then the only
|
||||
// honest signals of liveness left, so losing them in parsing would put the bar back to looking hung.
|
||||
func TestParseResticStatusKeepsCurrentFileAndElapsed(t *testing.T) {
|
||||
line := `{"message_type":"status","seconds_elapsed":42,"percent_done":0,"total_files":46,` +
|
||||
`"files_done":1,"total_bytes":451130451,"current_files":["/mnt/hdd/felhom-data/backups/primary/immich/volumes/immich_upload.tar"]}`
|
||||
r, ok := parseResticStatus(line)
|
||||
if !ok {
|
||||
t.Fatal("status line was not parsed")
|
||||
}
|
||||
if r.ElapsedSec != 42 {
|
||||
t.Errorf("elapsed = %d, want 42", r.ElapsedSec)
|
||||
}
|
||||
if r.CurrentFile == "" {
|
||||
t.Fatal("current_file lost — with no counter moving this is the only liveness signal left")
|
||||
}
|
||||
if want := "immich_upload.tar"; !strings.HasSuffix(r.CurrentFile, want) {
|
||||
t.Errorf("current_file = %q, want it to end in %q", r.CurrentFile, want)
|
||||
}
|
||||
}
|
||||
|
||||
// TestProgressKeepsLastKnownCurrentFile — restic omits current_files on some status ticks. Blanking
|
||||
// the label every other second is its own kind of flicker, so the last known value must persist.
|
||||
func TestProgressKeepsLastKnownCurrentFile(t *testing.T) {
|
||||
var st offboxProgressState
|
||||
st.begin()
|
||||
st.setApp("immich")
|
||||
st.update(resticProgress{CurrentFile: "/data/big.tar", ElapsedSec: 5, TotalFiles: 46, FilesDone: 1})
|
||||
st.update(resticProgress{CurrentFile: "", ElapsedSec: 7, TotalFiles: 46, FilesDone: 1}) // tick without current_files
|
||||
if got := st.snapshot().CurrentFile; got != "/data/big.tar" {
|
||||
t.Errorf("current_file = %q after a tick that omitted it, want the last known value", got)
|
||||
}
|
||||
if got := st.snapshot().ElapsedSec; got != 7 {
|
||||
t.Errorf("elapsed = %d, want it to keep advancing (7)", got)
|
||||
}
|
||||
// A new app must clear it — otherwise the previous app's file is shown against the next one.
|
||||
st.setApp("nextcloud")
|
||||
if got := st.snapshot().CurrentFile; got != "" {
|
||||
t.Errorf("current_file = %q after switching app, want cleared", got)
|
||||
}
|
||||
}
|
||||
|
||||
// TestParseResticStatusClampsPercent — restic has been seen to report percent_done slightly above 1
|
||||
// near completion. A bar wider than its track is a visible bug.
|
||||
func TestParseResticStatusClampsPercent(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user