From dd2a9d23f1b02eb9aee08850e33812003a5a8753 Mon Sep 17 00:00:00 2001 From: Ben Sarmiento Date: Wed, 6 Dec 2023 03:16:34 +0100 Subject: [PATCH] Fix deletes again --- internal/torrent/manager.go | 6 +++--- internal/torrent/types.go | 26 +++++++++++++------------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/internal/torrent/manager.go b/internal/torrent/manager.go index fe006b8..9acdff2 100644 --- a/internal/torrent/manager.go +++ b/internal/torrent/manager.go @@ -48,7 +48,7 @@ func NewTorrentManager(cfg config.ConfigInterface, api *realdebrid.RealDebrid, p Api: api, accessKeySet: set.NewStringSet(), latestState: &initialSate, - requiredVersion: "03.12.2023", + requiredVersion: "06.12.2023", workerPool: p, log: log, } @@ -111,7 +111,7 @@ func NewTorrentManager(cfg config.ConfigInterface, api *realdebrid.RealDebrid, p } func (t *TorrentManager) RefreshTorrents() { - instances, _, err := t.Api.GetTorrents(0) + instances, _, err := t.Api.GetTorrents(10) if err != nil { t.log.Warnf("Cannot get torrents: %v\n", err) return @@ -244,11 +244,11 @@ func (t *TorrentManager) getMoreInfo(rdTorrent realdebrid.Torrent) *Torrent { torrent.InProgressIDs.Add(info.ID) } - infoCache.Set(rdTorrent.ID, &torrent) err = t.writeTorrentToFile(rdTorrent.ID, &torrent) if err != nil { t.log.Warnf("Cannot write torrent to file: %v", err) } + infoCache.Set(rdTorrent.ID, &torrent) return &torrent } diff --git a/internal/torrent/types.go b/internal/torrent/types.go index c67834e..9fbacd3 100644 --- a/internal/torrent/types.go +++ b/internal/torrent/types.go @@ -1,7 +1,7 @@ package torrent import ( - oldjson "encoding/json" + stdjson "encoding/json" "strings" "github.com/debridmediamanager/zurg/pkg/realdebrid" @@ -26,9 +26,9 @@ type Torrent struct { func (t *Torrent) MarshalJSON() ([]byte, error) { type Alias Torrent temp := &struct { - SelectedFilesJson oldjson.RawMessage `json:"SelectedFiles"` - DownloadedIDsJson oldjson.RawMessage `json:"DownloadedIDs"` - InProgressIDsJson oldjson.RawMessage `json:"InProgressIDs"` + SelectedFilesJson stdjson.RawMessage `json:"SelectedFiles"` + DownloadedIDsJson stdjson.RawMessage `json:"DownloadedIDs"` + InProgressIDsJson stdjson.RawMessage `json:"InProgressIDs"` *Alias }{ Alias: (*Alias)(t), @@ -41,16 +41,16 @@ func (t *Torrent) MarshalJSON() ([]byte, error) { temp.SelectedFilesJson = selectedFilesJson if t.DownloadedIDs.IsEmpty() { - temp.DownloadedIDsJson = []byte("\"\"") + temp.DownloadedIDsJson = []byte(`""`) } else { - downloadedIDsStr := "\"" + strings.Join(t.DownloadedIDs.List(), ",") + "\"" + downloadedIDsStr := `"` + strings.Join(t.DownloadedIDs.List(), ",") + `"` temp.DownloadedIDsJson = []byte(downloadedIDsStr) } if t.InProgressIDs.IsEmpty() { - temp.InProgressIDsJson = []byte("\"\"") + temp.InProgressIDsJson = []byte(`""`) } else { - inProgressIDsStr := "\"" + strings.Join(t.InProgressIDs.List(), ",") + "\"" + inProgressIDsStr := `"` + strings.Join(t.InProgressIDs.List(), ",") + `"` temp.InProgressIDsJson = []byte(inProgressIDsStr) } @@ -60,9 +60,9 @@ func (t *Torrent) MarshalJSON() ([]byte, error) { func (t *Torrent) UnmarshalJSON(data []byte) error { type Alias Torrent temp := &struct { - SelectedFilesJson oldjson.RawMessage `json:"SelectedFiles"` - DownloadedIDsJson oldjson.RawMessage `json:"DownloadedIDs"` - InProgressIDsJson oldjson.RawMessage `json:"InProgressIDs"` + SelectedFilesJson stdjson.RawMessage `json:"SelectedFiles"` + DownloadedIDsJson stdjson.RawMessage `json:"DownloadedIDs"` + InProgressIDsJson stdjson.RawMessage `json:"InProgressIDs"` *Alias }{ Alias: (*Alias)(t), @@ -79,14 +79,14 @@ func (t *Torrent) UnmarshalJSON(data []byte) error { } if len(temp.DownloadedIDsJson) > 2 { - downloadedIDs := strings.Split(string(temp.DownloadedIDsJson), ",") + downloadedIDs := strings.Split(strings.ReplaceAll(string(temp.DownloadedIDsJson), `"`, ""), ",") t.DownloadedIDs = strset.New(downloadedIDs...) } else { t.DownloadedIDs = strset.New() } if len(temp.InProgressIDsJson) > 2 { - inProgressIDs := strings.Split(string(temp.InProgressIDsJson), ",") + inProgressIDs := strings.Split(strings.ReplaceAll(string(temp.InProgressIDsJson), `"`, ""), ",") t.InProgressIDs = strset.New(inProgressIDs...) } else { t.InProgressIDs = strset.New()