[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:
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user