-// 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
+func (t *Torrent) CancelPieces(begin, end pieceIndex) {
+ t.cl.lock()
+ t.cancelPiecesLocked(begin, end, "Torrent.CancelPieces")
+ t.cl.unlock()
+}
+
+func (t *Torrent) cancelPiecesLocked(begin, end pieceIndex, reason string) {
+ for i := begin; i < end; i++ {
+ p := &t.pieces[i]
+ if p.priority == PiecePriorityNone {
+ continue
+ }
+ p.priority = PiecePriorityNone
+ t.updatePiecePriority(i, reason)