Clone set before modifying

This commit is contained in:
Ben Sarmiento
2024-05-27 17:17:45 +02:00
parent f28255a142
commit 964fdfcbf9
5 changed files with 25 additions and 14 deletions

View File

@@ -15,7 +15,12 @@ import (
cmap "github.com/orcaman/concurrent-map/v2"
)
func inProgressStatus(status string) bool {
return status == "downloading" || status == "uploading" || status == "queued" || status == "compressing"
}
func (t *TorrentManager) refreshTorrents() []string {
t.inProgressHashes = mapset.NewSet[string]()
instances, _, err := t.api.GetTorrents(false)
if err != nil {
t.log.Warnf("Cannot get torrents: %v", err)
@@ -40,6 +45,9 @@ func (t *TorrentManager) refreshTorrents() []string {
if t.binImmediately(instances[idx].ID) ||
t.binOnceDoneErrorCheck(instances[idx].ID, instances[idx].Status) ||
instances[idx].Progress != 100 {
if inProgressStatus(instances[idx].Status) {
t.inProgressHashes.Add(instances[idx].Hash)
}
mergeChan <- nil
return
}