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

@@ -24,12 +24,11 @@ func (t *TorrentManager) Delete(accessKey string, deleteInRD bool) {
allTorrents, _ := t.DirectoryMap.Get(INT_ALL)
if torrent, ok := allTorrents.Get(accessKey); ok {
if deleteInRD {
torrent.DownloadedIDs.Each(func(torrentID string) bool {
torrent.DownloadedIDs.Clone().Each(func(torrentID string) bool {
t.log.Debugf("Deleting torrent %s (id=%s) in RD", accessKey, torrentID)
t.api.DeleteTorrent(torrentID)
t.deleteInfoFile(torrentID)
return false
})
}
}