Init torepair set properly

This commit is contained in:
Ben Sarmiento
2024-01-26 13:05:37 +01:00
parent 58b0b8b917
commit d2b69f9759

View File

@@ -28,7 +28,7 @@ func (t *TorrentManager) repairAll() {
allTorrents, _ := t.DirectoryMap.Get(INT_ALL)
// collect all torrents that need to be repaired
var toRepair mapset.Set[*Torrent]
toRepair := mapset.NewSet[*Torrent]()
allTorrents.IterCb(func(_ string, torrent *Torrent) {
if torrent.AnyInProgress() || torrent.UnrepairableReason != "" {
@@ -80,13 +80,18 @@ func (t *TorrentManager) repairAll() {
return
}
})
t.log.Debugf("Found %d broken torrents to repair in total", toRepair.Cardinality())
if toRepair.Cardinality() == 0 {
t.log.Info("Periodic repair found no broken torrents to repair")
} 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) {
if torrent.UnrepairableReason != "" {