]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Change the behaviour of Torrent.Length with when info isn't available
authorMatt Joiner <anacrolix@gmail.com>
Wed, 20 Apr 2016 10:10:39 +0000 (20:10 +1000)
committerMatt Joiner <anacrolix@gmail.com>
Wed, 20 Apr 2016 10:10:39 +0000 (20:10 +1000)
t.go

diff --git a/t.go b/t.go
index 31515c53090235120c7348cab5a7e1d8be6a1024..eb292c915f0cd7de3b0443dfbf51fb594a4fdafe 100644 (file)
--- a/t.go
+++ b/t.go
@@ -104,12 +104,10 @@ func (t *Torrent) Name() string {
 // The completed length of all the torrent data, in all its files. This is
 // derived from the torrent info, when it is available.
 func (t *Torrent) Length() int64 {
-       select {
-       case <-t.GotInfo():
-               return t.length
-       default:
-               return -1
+       if t.info == nil {
+               panic("not valid until info obtained")
        }
+       return t.length
 }
 
 // Returns a run-time generated metainfo for the torrent that includes the