]> Sergey Matveev's repositories - meta4ra.git/commitdiff
Do not fail if size is unknown
authorSergey Matveev <stargrave@stargrave.org>
Fri, 27 Feb 2026 08:55:16 +0000 (11:55 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Fri, 27 Feb 2026 08:55:16 +0000 (11:55 +0300)
cmd/progress.go

index ad49af57358219d1088a39179c311d89a18def8d..86a1ca647472cd741f526c502afa4dd879153ace 100644 (file)
@@ -38,10 +38,14 @@ func (p *Progress) Write(data []byte) (n int, err error) {
        p.now = time.Now()
        if p.now.After(p.next) {
                p.next = p.now.Add(ProgressPeriod)
-               fmt.Fprintf(os.Stderr, "%d%% | %s / %s\n",
-                       int(100*p.wrote/p.total),
-                       humanize.IBytes(p.wrote),
-                       humanize.IBytes(p.total))
+               if p.total == 0 {
+                       fmt.Fprintf(os.Stderr, "%s\n", humanize.IBytes(p.wrote))
+               } else {
+                       fmt.Fprintf(os.Stderr, "%d%% | %s / %s\n",
+                               int(100*p.wrote/p.total),
+                               humanize.IBytes(p.wrote),
+                               humanize.IBytes(p.total))
+               }
        }
        return
 }