projects
/
btrtrc.git
/ commitdiff
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
434c954
)
Fix crash printing client status when a torrent info isn't available
author
Matt Joiner <anacrolix@gmail.com>
Sun, 29 Jun 2014 08:56:19 +0000 (18:56 +1000)
committer
Matt Joiner <anacrolix@gmail.com>
Sun, 29 Jun 2014 08:56:19 +0000 (18:56 +1000)
client.go
patch
|
blob
|
history
diff --git
a/client.go
b/client.go
index 2e60d9b623f546b8993876acd06586aae69adbbf..ad1afff68a756896f18dc8f0807214e1d6877562 100644
(file)
--- a/
client.go
+++ b/
client.go
@@
-118,7
+118,13
@@
func (cl *Client) WriteStatus(w io.Writer) {
cl.mu.Lock()
defer cl.mu.Unlock()
for _, t := range cl.torrents {
- fmt.Fprintf(w, "%s: %f%%\n", t.Name(), 100*(1-float32(t.BytesLeft())/float32(t.Length())))
+ fmt.Fprintf(w, "%s: %f%%\n", t.Name(), func() float32 {
+ if !t.haveInfo() {
+ return 0
+ } else {
+ return 100 * (1 - float32(t.BytesLeft())/float32(t.Length()))
+ }
+ }())
t.WriteStatus(w)
}
}