Refactors 2
This commit is contained in:
@@ -64,17 +64,6 @@ func (t *TorrentManager) willDeleteOnceDone(torrentId string) {
|
||||
t.persistBins()
|
||||
}
|
||||
|
||||
func (t *TorrentManager) cleanupBins(freshIDs mapset.Set[string]) {
|
||||
t.OnceDoneBin.Clone().Each(func(entry string) bool {
|
||||
// check for: delete once done cases
|
||||
if !freshIDs.ContainsOne(entry) {
|
||||
t.OnceDoneBin.Remove(entry)
|
||||
}
|
||||
return false
|
||||
})
|
||||
t.persistBins()
|
||||
}
|
||||
|
||||
// deleteOnceDone checks if the torrent is in the OnceDoneBin and deletes it if it is.
|
||||
// returns true if the torrent was in the bin and was deleted, false otherwise
|
||||
func (t *TorrentManager) deleteOnceDone(completedTorrentId string, failed bool) {
|
||||
|
||||
@@ -52,7 +52,6 @@ type TorrentManager struct {
|
||||
|
||||
latestState *LibraryState
|
||||
|
||||
repairChan chan *Torrent
|
||||
RepairQueue mapset.Set[*Torrent]
|
||||
repairRunning bool
|
||||
repairRunningMu sync.Mutex
|
||||
|
||||
@@ -71,10 +71,6 @@ func (t *TorrentManager) refreshTorrents(initialRun bool) {
|
||||
})
|
||||
}
|
||||
|
||||
t.workerPool.Submit(func() {
|
||||
t.cleanupBins(freshIDs)
|
||||
})
|
||||
|
||||
wg.Wait()
|
||||
close(mergeChan)
|
||||
|
||||
@@ -116,6 +112,17 @@ func (t *TorrentManager) refreshTorrents(initialRun bool) {
|
||||
|
||||
t.log.Infof("Compiled into %d unique torrents", allTorrents.Count())
|
||||
|
||||
t.workerPool.Submit(func() {
|
||||
t.OnceDoneBin.Clone().Each(func(entry string) bool {
|
||||
// check for: delete once done cases
|
||||
if !freshIDs.ContainsOne(entry) {
|
||||
t.OnceDoneBin.Remove(entry)
|
||||
}
|
||||
return false
|
||||
})
|
||||
t.persistBins()
|
||||
})
|
||||
|
||||
// delete info files that are no longer present
|
||||
// it also runs binOnceDone (needed for cleanup every refresh)
|
||||
t.getInfoFiles().Each(func(path string) bool {
|
||||
|
||||
@@ -26,7 +26,6 @@ func (t *TorrentManager) StartRepairJob() {
|
||||
return
|
||||
}
|
||||
|
||||
t.repairChan = make(chan *Torrent)
|
||||
t.RepairQueue = mapset.NewSet[*Torrent]()
|
||||
t.RepairAllTrigger = make(chan struct{})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user