defer seeder.Close()
// Adding a torrent and setting the info should trigger piece checks for everything
// automatically. Wait until the seed Torrent agrees that everything is available.
- <-seederTorrent.Complete.On()
+ <-seederTorrent.Complete().On()
// Create leecher and a Torrent.
leecherDataDir := t.TempDir()
cfg = torrent.TestingConfig(t)
return
}())
require.NoError(t, err)
- assert.False(t, leecherTorrent.Complete.Bool())
+ assert.False(t, leecherTorrent.Complete().Bool())
assert.True(t, new)
//// This was used when observing coalescing of piece state changes.
go leecherTorrent.VerifyData()
}
if canComplete {
- <-leecherTorrent.Complete.On()
+ <-leecherTorrent.Complete().On()
} else {
- <-leecherTorrent.Complete.Off()
+ <-leecherTorrent.Complete().Off()
}
assert.NotEmpty(t, seederTorrent.PeerConns())
leecherPeerConns := leecherTorrent.PeerConns()
go func() {
for range time.Tick(time.Second * 5) {
for _, torrent := range client.Torrents() {
- if torrent.Complete.Bool() {
+ if torrent.Complete().Bool() {
fmt.Println("Dropping torrent", torrent.InfoHash().HexString())
torrent.Drop()
}
pex pexState
// Is On when all pieces are complete.
- Complete chansync.Flag
+ complete chansync.Flag
// Torrent sources in use keyed by the source string.
activeSources sync.Map
}
func (t *Torrent) updateComplete() {
- t.Complete.SetBool(t.haveAllPieces())
+ t.complete.SetBool(t.haveAllPieces())
}
func (t *Torrent) cancelRequest(r RequestIndex) *Peer {
}
return
}
+
+// Is On when all pieces are complete.
+func (t *Torrent) Complete() chansync.ReadOnlyFlag {
+ return &t.complete
+}
defer tt.Drop()
tt.DownloadAll()
require.True(t, cl.WaitAll())
- assert.True(t, tt.Complete.Bool())
+ assert.True(t, tt.Complete().Bool())
assert.True(t, missinggo.FilePathExists(fp))
}