Add library update hook on repair all

This commit is contained in:
Ben Sarmiento
2023-12-07 15:58:22 +01:00
parent 10aac20030
commit 845a01d7f3
5 changed files with 18 additions and 10 deletions

View File

@@ -9,9 +9,8 @@ import (
func (t *TorrentManager) RepairAll() {
_ = t.repairWorker.Submit(func() {
t.log.Info("Checking for torrents to repair")
t.repairAll()
t.log.Info("Finished checking for torrents to repair")
t.log.Debug("Finished repairing all torrents")
})
}
@@ -27,10 +26,16 @@ func (t *TorrentManager) repairAll() {
}
})
t.log.Debugf("Found %d torrents to repair", len(toRepair))
var updatedPaths []string
for i := range toRepair {
t.log.Infof("Repairing %s", toRepair[i].AccessKey)
t.repair(toRepair[i])
torrent := toRepair[i]
t.log.Infof("Repairing %s", torrent.AccessKey)
t.repair(torrent)
t.assignedDirectoryCb(torrent, func(directory string) {
updatedPaths = append(updatedPaths, fmt.Sprintf("%s/%s", directory, torrent.AccessKey))
})
}
t.TriggerHookOnLibraryUpdate(updatedPaths)
}
func (t *TorrentManager) Repair(torrent *Torrent) {
@@ -205,7 +210,6 @@ func (t *TorrentManager) canCapacityHandle() bool {
}
if count.DownloadingCount < count.MaxNumberOfTorrents {
// t.log.Infof("We can still add a new torrent, we have capacity for %d more", count.MaxNumberOfTorrents-count.DownloadingCount)
return true
}