Prevent race condition with downloaded id

This commit is contained in:
Ben Sarmiento
2024-02-05 03:27:45 +01:00
parent dcdb83349a
commit c8bbfc8650
4 changed files with 38 additions and 26 deletions

View File

@@ -14,7 +14,7 @@ import (
cmap "github.com/orcaman/concurrent-map/v2"
)
func (t *TorrentManager) refreshTorrents() []string {
func (t *TorrentManager) refreshTorrents(isInitialRun bool) []string {
instances, _, err := t.Api.GetTorrents(0, false)
if err != nil {
t.log.Warnf("Cannot get torrents: %v", err)
@@ -87,9 +87,14 @@ func (t *TorrentManager) refreshTorrents() []string {
})
if t.Config.EnableRepair() {
t.workerPool.Submit(func() {
t.handleFixers(instances)
})
if isInitialRun {
t.removeExpiredFixers(instances)
t.processFixers(instances)
} else {
t.workerPool.Submit(func() {
t.processFixers(instances)
})
}
}
return updatedPaths
@@ -112,7 +117,7 @@ func (t *TorrentManager) StartRefreshJob() {
t.log.Infof("Detected changes! Refreshing %d torrents", checksum.TotalCount)
t.setNewLatestState(checksum)
updatedPaths := t.refreshTorrents()
updatedPaths := t.refreshTorrents(false)
t.log.Info("Finished refreshing torrents")
t.TriggerHookOnLibraryUpdate(updatedPaths)