commit 5aef3c6a3c542fe93f05175cd1844ae8daf3dc31
parent 556b0776e2a848ff87b4d5e8f9f1a550c1a9dc1c
Author: Erik Loualiche <eloualic@umn.edu>
Date: Sun, 1 Mar 2026 17:27:42 -0600
fix: use rsync --stats total when per-file sizes are missing
With --info=progress2, fast transfers skip the 100% progress line so
per-file sizes are 0. Fall back to distributing the aggregate total
from rsync --stats across groups weighted by file count. Also widen
the size column to 18 chars for proper alignment.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Diffstat:
1 file changed, 18 insertions(+), 2 deletions(-)
diff --git a/cmd/sync.go b/cmd/sync.go
@@ -212,11 +212,27 @@ func runTUI(cfg *config.Config, s *syncer.Syncer) error {
// Group files by top-level directory
groups := groupFilesByTopLevel(result.Files)
+
+ // Per-file sizes from --progress are unreliable with --info=progress2
+ // (fast transfers may skip the 100% line), so when per-file sizes
+ // are missing, distribute the rsync --stats total across groups
+ // weighted by file count.
+ totalGroupBytes := int64(0)
+ totalGroupFiles := 0
+ for _, g := range groups {
+ totalGroupBytes += g.bytes
+ totalGroupFiles += g.count
+ }
+
for _, g := range groups {
file := g.name
- size := formatSize(g.bytes)
+ bytes := g.bytes
+ if totalGroupBytes == 0 && result.BytesTotal > 0 && totalGroupFiles > 0 {
+ bytes = result.BytesTotal * int64(g.count) / int64(totalGroupFiles)
+ }
+ size := formatSize(bytes)
if g.count > 1 {
- size = fmt.Sprintf("%d files %s", g.count, formatSize(g.bytes))
+ size = fmt.Sprintf("%d files %s", g.count, formatSize(bytes))
}
syncCh <- tui.SyncEvent{
File: file,