Refresh all piece completion states when data is missing
This commit is contained in:
parent
99e9f41a33
commit
5b443fb63d
@ -136,8 +136,8 @@ func (r *Reader) readOnceAt(b []byte, pos int64) (n int, err error) {
|
|||||||
}
|
}
|
||||||
log.Printf("%s: error reading from torrent storage pos=%d: %s", r.t, pos, err)
|
log.Printf("%s: error reading from torrent storage pos=%d: %s", r.t, pos, err)
|
||||||
r.t.cl.mu.Lock()
|
r.t.cl.mu.Lock()
|
||||||
r.t.torrent.updatePieceCompletion(pi)
|
r.t.torrent.updateAllPieceCompletions()
|
||||||
r.t.torrent.updatePiecePriority(pi)
|
r.t.torrent.updatePiecePriorities()
|
||||||
r.t.cl.mu.Unlock()
|
r.t.cl.mu.Unlock()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@ import (
|
|||||||
"github.com/anacrolix/missinggo/itertools"
|
"github.com/anacrolix/missinggo/itertools"
|
||||||
"github.com/anacrolix/missinggo/perf"
|
"github.com/anacrolix/missinggo/perf"
|
||||||
"github.com/anacrolix/missinggo/pubsub"
|
"github.com/anacrolix/missinggo/pubsub"
|
||||||
|
"github.com/bradfitz/iter"
|
||||||
|
|
||||||
"github.com/anacrolix/torrent/bencode"
|
"github.com/anacrolix/torrent/bencode"
|
||||||
"github.com/anacrolix/torrent/metainfo"
|
"github.com/anacrolix/torrent/metainfo"
|
||||||
@ -1050,3 +1051,9 @@ func (t *torrent) readAt(b []byte, off int64) (n int, err error) {
|
|||||||
}
|
}
|
||||||
return t.data.ReadAt(b, off)
|
return t.data.ReadAt(b, off)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (t *torrent) updateAllPieceCompletions() {
|
||||||
|
for i := range iter.N(t.numPieces()) {
|
||||||
|
t.updatePieceCompletion(i)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user