fix: progress always at 0% and context cancelled before sendDocument
All checks were successful
CI / build (push) Successful in 50s

- Fix progress template: remove spurious stderr: prefix and switch to
  _percent_str/_speed_str/_eta_str keys (progress.percent outputs NA
  for HLS streams with unknown total size)
- Update progress regex to match new template format:
  DLPROG| 45.2%|   1.05MiB/s|00:45
- Fix context cancellation bug: clearActiveJob was cancelling dlCtx
  before handleDownloadCompletion could send the document
- Update progress test cases to match new template output format
This commit is contained in:
2026-06-25 23:49:27 +03:30
parent 37e7f918d0
commit 7c02cd3d89
4 changed files with 22 additions and 8 deletions

View File

@@ -109,21 +109,21 @@ func TestParseProgressTemplate(t *testing.T) {
hasRes bool
}{
{
line: "DLPROG|45.2|2.34MiB/s|00:45",
line: "DLPROG| 45.2%| 2.34MiB/s|00:45",
pct: 45.2,
speed: "2.34MiB/s",
eta: "00:45",
hasRes: true,
},
{
line: "DLPROG|100.0|5.00MiB/s|00:00",
line: "DLPROG|100.0%| 5.00MiB/s|00:00",
pct: 100.0,
speed: "5.00MiB/s",
eta: "00:00",
hasRes: true,
},
{
line: "DLPROG|0.0||",
line: "DLPROG| 0.0%||",
pct: 0.0,
speed: "",
eta: "",
@@ -142,12 +142,26 @@ func TestParseProgressTemplate(t *testing.T) {
hasRes: false,
},
{
line: "DLPROG|50.0|Unknown|Unknown",
line: "DLPROG| 50.0%| Unknown|Unknown",
pct: 50.0,
speed: "",
eta: "",
hasRes: true,
},
{
line: "DLPROG| 16.7%| 1.05KiB/s|Unknown",
pct: 16.7,
speed: "1.05KiB/s",
eta: "",
hasRes: true,
},
{
line: "DLPROG| 11.1%| 754.59KiB/s|00:08",
pct: 11.1,
speed: "754.59KiB/s",
eta: "00:08",
hasRes: true,
},
}
for _, tt := range tests {
got := parseProgressTemplate(tt.line)