Init torepair set properly
This commit is contained in:
@@ -28,7 +28,7 @@ func (t *TorrentManager) repairAll() {
|
|||||||
allTorrents, _ := t.DirectoryMap.Get(INT_ALL)
|
allTorrents, _ := t.DirectoryMap.Get(INT_ALL)
|
||||||
|
|
||||||
// collect all torrents that need to be repaired
|
// collect all torrents that need to be repaired
|
||||||
var toRepair mapset.Set[*Torrent]
|
toRepair := mapset.NewSet[*Torrent]()
|
||||||
|
|
||||||
allTorrents.IterCb(func(_ string, torrent *Torrent) {
|
allTorrents.IterCb(func(_ string, torrent *Torrent) {
|
||||||
if torrent.AnyInProgress() || torrent.UnrepairableReason != "" {
|
if torrent.AnyInProgress() || torrent.UnrepairableReason != "" {
|
||||||
@@ -80,12 +80,17 @@ func (t *TorrentManager) repairAll() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
t.log.Debugf("Found %d broken torrents to repair in total", toRepair.Cardinality())
|
|
||||||
|
|
||||||
toRepair.Each(func(torrent *Torrent) bool {
|
if toRepair.Cardinality() == 0 {
|
||||||
t.Repair(torrent)
|
t.log.Info("Periodic repair found no broken torrents to repair")
|
||||||
return false
|
} else {
|
||||||
})
|
t.log.Debugf("Periodic repair found %d broken torrents to repair in total", toRepair.Cardinality())
|
||||||
|
|
||||||
|
toRepair.Each(func(torrent *Torrent) bool {
|
||||||
|
t.Repair(torrent)
|
||||||
|
return false
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *TorrentManager) Repair(torrent *Torrent) {
|
func (t *TorrentManager) Repair(torrent *Torrent) {
|
||||||
|
|||||||
Reference in New Issue
Block a user