torrent.go | 27 +++++++++++++++------------ diff --git a/torrent.go b/torrent.go index 2d791aab455c811cfc3d30e9af2d8cd81ed621ef..50e2ed91c73f0566c18c48ed111757a3e9f6c861 100644 --- a/torrent.go +++ b/torrent.go @@ -381,17 +381,19 @@ func (t *torrent) writeStatus(w io.Writer, cl *Client) { fmt.Fprintf(w, "Infohash: %x\n", t.InfoHash) fmt.Fprintf(w, "Metadata length: %d\n", t.metadataSize()) - fmt.Fprintf(w, "Metadata have: ") - for _, h := range t.metadataHave { - fmt.Fprintf(w, "%c", func() rune { - if h { - return 'H' - } else { - return '.' - } - }()) + if !t.haveInfo() { + fmt.Fprintf(w, "Metadata have: ") + for _, h := range t.metadataHave { + fmt.Fprintf(w, "%c", func() rune { + if h { + return 'H' + } else { + return '.' + } + }()) + } + fmt.Fprintln(w) } - fmt.Fprintln(w) fmt.Fprintf(w, "Piece length: %s\n", func() string { if t.haveInfo() { return fmt.Sprint(t.usualPieceSize()) @@ -427,7 +429,8 @@ c: t.Conns, t: t, cl: cl, }) - for _, c := range t.Conns { + for i, c := range t.Conns { + fmt.Fprintf(w, "%2d. ", i+1) c.WriteStatus(w, t) } } @@ -441,7 +444,7 @@ return s } func (t *torrent) haveInfo() bool { - return t.Info != nil + return t != nil && t.Info != nil } // TODO: Include URIs that weren't converted to tracker clients.