Prevent race condition with downloaded id
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user