Keep the progress line of a multi-path snapshot within 100% (closes #271)
check / check (push) Waiting to run

One progress reporter spans every path of a snapshot. Its counts of
files and bytes processed run across all the paths, while the totals
they were divided by were reset to each path's own, so a second path
smaller than the first showed more than 100% and an ETA of `unknown`.
The totals now add up over the paths scanned so far, and the
processing start time the rate is measured from is the first path's.
SetTotalSize is renamed AddTotalSize because it now adds.

The issue says the ETA went negative; it was computed negative and
printed as `unknown`.

Model: opus-5-5
This commit is contained in:
2026-10-08 01:48:40 +00:00
parent fce253fa39
commit b4284b2170
4 changed files with 119 additions and 9 deletions
+14 -7
View File
@@ -67,9 +67,9 @@ type ProgressStats struct {
BlobsUploaded atomic.Int64
BytesUploaded atomic.Int64
CurrentFile atomic.Value // stores string
TotalSize atomic.Int64 // Total size to process (set after scan phase)
TotalFiles atomic.Int64 // Total files to process in phase 2
ProcessStartTime atomic.Value // stores time.Time when processing starts
TotalSize atomic.Int64 // Size to process in the paths scanned so far
TotalFiles atomic.Int64 // Files to process in the paths scanned so far
ProcessStartTime atomic.Value // stores time.Time; set by the first path
StartTime time.Time
mu sync.RWMutex
lastDetailTime time.Time
@@ -148,10 +148,17 @@ func (pr *ProgressReporter) GetStats() *ProgressStats {
return pr.stats
}
// SetTotalSize sets the total size to process (after scan phase)
func (pr *ProgressReporter) SetTotalSize(size int64) {
pr.stats.TotalSize.Store(size)
pr.stats.ProcessStartTime.Store(time.Now().UTC())
// AddTotalSize adds the size one path of the snapshot has to process to
// the total, once that path's scan phase is done. The processed counts
// run across every path, so the total does too, and the processing start
// time, which the rate is measured from, is the first path's.
func (pr *ProgressReporter) AddTotalSize(size int64) {
pr.stats.TotalSize.Add(size)
_, started := pr.stats.ProcessStartTime.Load().(time.Time)
if !started {
pr.stats.ProcessStartTime.Store(time.Now().UTC())
}
}
// Helper functions