fmt.Fprint(w, t.name())
}
fmt.Fprint(w, "\n")
- if t.Info() != nil {
- fmt.Fprintf(w, "%f%% of %d bytes (%s)", 100*(1-float64(t.bytesMissingLocked())/float64(t.Info().TotalLength())), t.length, humanize.Bytes(uint64(t.Info().TotalLength())))
+ if t.info != nil {
+ fmt.Fprintf(w, "%f%% of %d bytes (%s)", 100*(1-float64(t.bytesMissingLocked())/float64(t.info.TotalLength())), t.length, humanize.Bytes(uint64(t.info.TotalLength())))
} else {
w.WriteString("<missing metainfo>")
}
}
}
b1 := b[:avail]
- pi := int(pos / r.t.Info().PieceLength)
- ip := r.t.Info().Piece(pi)
- po := pos % r.t.Info().PieceLength
+ pi := int(pos / r.t.info.PieceLength)
+ ip := r.t.info.Piece(pi)
+ po := pos % r.t.info.PieceLength
missinggo.LimitLen(&b1, ip.Length()-po)
n, err = r.t.readAt(b1, pos)
if n != 0 {
// Returns the metainfo info dictionary, or nil if it's not yet available.
func (t *Torrent) Info() *metainfo.Info {
+ t.cl.mu.Lock()
+ defer t.cl.mu.Unlock()
return t.info
}
// Returns handles to the files in the torrent. This requires the metainfo is
// available first.
func (t *Torrent) Files() (ret []File) {
- t.cl.mu.Lock()
info := t.Info()
- t.cl.mu.Unlock()
if info == nil {
return
}
return "?"
}
}())
- if t.Info() != nil {
+ if t.info != nil {
fmt.Fprintf(w, "Num Pieces: %d\n", t.numPieces())
fmt.Fprint(w, "Piece States:")
for _, psr := range t.pieceStateRuns() {