[fix] Report the unit in a single scan job (#4209)

* [fix] Report the unit in a single scan job

* Eliminate divide by 0 possibility
This commit is contained in:
Miccah
2025-06-05 09:17:26 -07:00
committed by GitHub
parent 8b6aac3fcd
commit ab1b459b2b
2 changed files with 5 additions and 0 deletions
+4
View File
@@ -355,6 +355,10 @@ func (m JobProgressMetrics) PercentComplete() int {
// Fallback to the source's self-reported percent complete if
// the unit information isn't available.
return int(m.SourcePercent)
} else if den == 0 {
// This should never happen. Return an invalid value so we can
// trace it back to here if we ever see it.
return -1
}
return int(num * 100 / den)
}
+1
View File
@@ -417,6 +417,7 @@ func (s *SourceManager) scan(ctx context.Context, source Source, report *JobProg
}
}()
report.ReportUnit(unit)
report.TrackProgress(source.GetProgress())
if ctx.Value("job_id") == "" {
ctx = context.WithValue(ctx, "job_id", report.JobID)