]> Sergey Matveev's repositories - btrtrc.git/commitdiff
cmd/torrent: Fix progress bar for zero-length torrents
authorMatt Joiner <anacrolix@gmail.com>
Mon, 12 Sep 2016 07:47:07 +0000 (17:47 +1000)
committerMatt Joiner <anacrolix@gmail.com>
Mon, 12 Sep 2016 07:47:07 +0000 (17:47 +1000)
cmd/torrent/main.go

index 358ef9edf7fe92df1554a9fffb6510bd8e4fbafe..f27e57247c38695928d8a3c1a0b3c157463b21e6 100644 (file)
@@ -57,7 +57,12 @@ func torrentBar(t *torrent.Torrent) {
        })
        go func() {
                <-t.GotInfo()
-               bar.Total = int(t.Info().TotalLength())
+               tl := int(t.Info().TotalLength())
+               if tl == 0 {
+                       bar.Set(1)
+                       return
+               }
+               bar.Total = tl
                for {
                        bc := t.BytesCompleted()
                        bar.Set(int(bc))