32bit compatibility

This commit is contained in:
Ben Sarmiento
2024-01-06 17:30:17 +01:00
parent a3eab1752c
commit d93fd2cdc1
6 changed files with 28 additions and 33 deletions

View File

@@ -8,9 +8,8 @@ import (
"time"
"github.com/debridmediamanager/zurg/pkg/realdebrid"
mapset "github.com/deckarep/golang-set/v2"
cmap "github.com/orcaman/concurrent-map/v2"
"github.com/scylladb/go-set"
"github.com/scylladb/go-set/strset"
)
func (t *TorrentManager) RefreshTorrents() []string {
@@ -35,7 +34,7 @@ func (t *TorrentManager) RefreshTorrents() []string {
close(infoChan)
t.log.Debugf("Fetched info for %d torrents", len(instances))
freshKeys := set.NewStringSet()
freshKeys := mapset.NewSet[string]()
allTorrents, _ := t.DirectoryMap.Get(INT_ALL)
noInfoCount := 0
for info := range infoChan {
@@ -48,7 +47,7 @@ func (t *TorrentManager) RefreshTorrents() []string {
}
if torrent, exists := allTorrents.Get(info.AccessKey); !exists {
allTorrents.Set(info.AccessKey, info)
} else if !strset.Difference(info.DownloadedIDs, torrent.DownloadedIDs).IsEmpty() {
} else if !info.DownloadedIDs.Difference(torrent.DownloadedIDs).IsEmpty() {
mainTorrent := t.mergeToMain(torrent, info)
allTorrents.Set(info.AccessKey, &mainTorrent)
}
@@ -56,7 +55,7 @@ func (t *TorrentManager) RefreshTorrents() []string {
t.log.Infof("Compiled into %d torrents, %d were missing info", allTorrents.Count(), noInfoCount)
var updatedPaths []string
// torrents yet to be assigned in a directory
strset.Difference(freshKeys, t.allAccessKeys).Each(func(accessKey string) bool {
freshKeys.Difference(t.allAccessKeys).Each(func(accessKey string) bool {
// assign to directories
tor, ok := allTorrents.Get(accessKey)
if !ok {
@@ -79,8 +78,7 @@ func (t *TorrentManager) RefreshTorrents() []string {
return true
})
// removed torrents
// items which are in in t.allAccessKeys but not in freshKeys
strset.Difference(t.allAccessKeys, freshKeys).Each(func(accessKey string) bool {
t.allAccessKeys.Difference(freshKeys).Each(func(accessKey string) bool {
t.Delete(accessKey, false)
return true
})
@@ -188,8 +186,8 @@ func (t *TorrentManager) getMoreInfo(rdTorrent realdebrid.Torrent) *Torrent {
torrent.SelectedFiles.Set(filepath.Base(file.Path), file)
}
}
torrent.DownloadedIDs = strset.New()
torrent.InProgressIDs = strset.New()
torrent.DownloadedIDs = mapset.NewSet[string]()
torrent.InProgressIDs = mapset.NewSet[string]()
if info.Progress == 100 {
torrent.DownloadedIDs.Add(info.ID)
} else {
@@ -207,11 +205,11 @@ func (t *TorrentManager) mergeToMain(existing, toMerge *Torrent) Torrent {
mainTorrent.AccessKey = existing.AccessKey
mainTorrent.Hash = existing.Hash
mainTorrent.DownloadedIDs = strset.New()
mainTorrent.InProgressIDs = strset.New()
mainTorrent.DownloadedIDs = mapset.NewSet[string]()
mainTorrent.InProgressIDs = mapset.NewSet[string]()
// this function triggers only when we have a new DownloadedID
strset.Difference(toMerge.DownloadedIDs, existing.DownloadedIDs).Each(func(id string) bool {
toMerge.DownloadedIDs.Difference(existing.DownloadedIDs).Each(func(id string) bool {
mainTorrent.DownloadedIDs.Add(id)
mainTorrent.InProgressIDs.Remove(id)
return true