package torrent import cmap "github.com/orcaman/concurrent-map/v2" func (t *TorrentManager) CheckDeletedState(torrent *Torrent) bool { var unselectedIDs []int torrent.SelectedFiles.IterCb(func(_ string, file *File) { if file.Link == "unselect" { unselectedIDs = append(unselectedIDs, file.ID) } }) if len(unselectedIDs) == torrent.SelectedFiles.Count() && len(unselectedIDs) > 0 { return true } else if len(unselectedIDs) > 0 { torrent.DownloadedIDs.Each(func(id string) bool { t.writeTorrentToFile(id, torrent) return true }) } return false } func (t *TorrentManager) Delete(accessKey string, deleteInRD bool) { allTorrents, _ := t.DirectoryMap.Get(INT_ALL) if deleteInRD { infoCache, _ := t.DirectoryMap.Get(INT_INFO_CACHE) if torrent, ok := allTorrents.Get(accessKey); ok { torrent.DownloadedIDs.Each(func(id string) bool { t.log.Debugf("Deleting torrent %s %s in RD", id, accessKey) t.Api.DeleteTorrent(id) infoCache.Remove(id) t.deleteTorrentFile(id) return true }) } } t.allAccessKeys.Remove(accessKey) t.log.Infof("Removing torrent %s from zurg database", accessKey) t.DirectoryMap.IterCb(func(directory string, torrents cmap.ConcurrentMap[string, *Torrent]) { torrents.Remove(accessKey) }) allTorrents.Remove(accessKey) }