Fix deletes again
This commit is contained in:
@@ -48,7 +48,7 @@ func NewTorrentManager(cfg config.ConfigInterface, api *realdebrid.RealDebrid, p
|
|||||||
Api: api,
|
Api: api,
|
||||||
accessKeySet: set.NewStringSet(),
|
accessKeySet: set.NewStringSet(),
|
||||||
latestState: &initialSate,
|
latestState: &initialSate,
|
||||||
requiredVersion: "03.12.2023",
|
requiredVersion: "06.12.2023",
|
||||||
workerPool: p,
|
workerPool: p,
|
||||||
log: log,
|
log: log,
|
||||||
}
|
}
|
||||||
@@ -111,7 +111,7 @@ func NewTorrentManager(cfg config.ConfigInterface, api *realdebrid.RealDebrid, p
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (t *TorrentManager) RefreshTorrents() {
|
func (t *TorrentManager) RefreshTorrents() {
|
||||||
instances, _, err := t.Api.GetTorrents(0)
|
instances, _, err := t.Api.GetTorrents(10)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.log.Warnf("Cannot get torrents: %v\n", err)
|
t.log.Warnf("Cannot get torrents: %v\n", err)
|
||||||
return
|
return
|
||||||
@@ -244,11 +244,11 @@ func (t *TorrentManager) getMoreInfo(rdTorrent realdebrid.Torrent) *Torrent {
|
|||||||
torrent.InProgressIDs.Add(info.ID)
|
torrent.InProgressIDs.Add(info.ID)
|
||||||
}
|
}
|
||||||
|
|
||||||
infoCache.Set(rdTorrent.ID, &torrent)
|
|
||||||
err = t.writeTorrentToFile(rdTorrent.ID, &torrent)
|
err = t.writeTorrentToFile(rdTorrent.ID, &torrent)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.log.Warnf("Cannot write torrent to file: %v", err)
|
t.log.Warnf("Cannot write torrent to file: %v", err)
|
||||||
}
|
}
|
||||||
|
infoCache.Set(rdTorrent.ID, &torrent)
|
||||||
|
|
||||||
return &torrent
|
return &torrent
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package torrent
|
package torrent
|
||||||
|
|
||||||
import (
|
import (
|
||||||
oldjson "encoding/json"
|
stdjson "encoding/json"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/debridmediamanager/zurg/pkg/realdebrid"
|
"github.com/debridmediamanager/zurg/pkg/realdebrid"
|
||||||
@@ -26,9 +26,9 @@ type Torrent struct {
|
|||||||
func (t *Torrent) MarshalJSON() ([]byte, error) {
|
func (t *Torrent) MarshalJSON() ([]byte, error) {
|
||||||
type Alias Torrent
|
type Alias Torrent
|
||||||
temp := &struct {
|
temp := &struct {
|
||||||
SelectedFilesJson oldjson.RawMessage `json:"SelectedFiles"`
|
SelectedFilesJson stdjson.RawMessage `json:"SelectedFiles"`
|
||||||
DownloadedIDsJson oldjson.RawMessage `json:"DownloadedIDs"`
|
DownloadedIDsJson stdjson.RawMessage `json:"DownloadedIDs"`
|
||||||
InProgressIDsJson oldjson.RawMessage `json:"InProgressIDs"`
|
InProgressIDsJson stdjson.RawMessage `json:"InProgressIDs"`
|
||||||
*Alias
|
*Alias
|
||||||
}{
|
}{
|
||||||
Alias: (*Alias)(t),
|
Alias: (*Alias)(t),
|
||||||
@@ -41,16 +41,16 @@ func (t *Torrent) MarshalJSON() ([]byte, error) {
|
|||||||
temp.SelectedFilesJson = selectedFilesJson
|
temp.SelectedFilesJson = selectedFilesJson
|
||||||
|
|
||||||
if t.DownloadedIDs.IsEmpty() {
|
if t.DownloadedIDs.IsEmpty() {
|
||||||
temp.DownloadedIDsJson = []byte("\"\"")
|
temp.DownloadedIDsJson = []byte(`""`)
|
||||||
} else {
|
} else {
|
||||||
downloadedIDsStr := "\"" + strings.Join(t.DownloadedIDs.List(), ",") + "\""
|
downloadedIDsStr := `"` + strings.Join(t.DownloadedIDs.List(), ",") + `"`
|
||||||
temp.DownloadedIDsJson = []byte(downloadedIDsStr)
|
temp.DownloadedIDsJson = []byte(downloadedIDsStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
if t.InProgressIDs.IsEmpty() {
|
if t.InProgressIDs.IsEmpty() {
|
||||||
temp.InProgressIDsJson = []byte("\"\"")
|
temp.InProgressIDsJson = []byte(`""`)
|
||||||
} else {
|
} else {
|
||||||
inProgressIDsStr := "\"" + strings.Join(t.InProgressIDs.List(), ",") + "\""
|
inProgressIDsStr := `"` + strings.Join(t.InProgressIDs.List(), ",") + `"`
|
||||||
temp.InProgressIDsJson = []byte(inProgressIDsStr)
|
temp.InProgressIDsJson = []byte(inProgressIDsStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,9 +60,9 @@ func (t *Torrent) MarshalJSON() ([]byte, error) {
|
|||||||
func (t *Torrent) UnmarshalJSON(data []byte) error {
|
func (t *Torrent) UnmarshalJSON(data []byte) error {
|
||||||
type Alias Torrent
|
type Alias Torrent
|
||||||
temp := &struct {
|
temp := &struct {
|
||||||
SelectedFilesJson oldjson.RawMessage `json:"SelectedFiles"`
|
SelectedFilesJson stdjson.RawMessage `json:"SelectedFiles"`
|
||||||
DownloadedIDsJson oldjson.RawMessage `json:"DownloadedIDs"`
|
DownloadedIDsJson stdjson.RawMessage `json:"DownloadedIDs"`
|
||||||
InProgressIDsJson oldjson.RawMessage `json:"InProgressIDs"`
|
InProgressIDsJson stdjson.RawMessage `json:"InProgressIDs"`
|
||||||
*Alias
|
*Alias
|
||||||
}{
|
}{
|
||||||
Alias: (*Alias)(t),
|
Alias: (*Alias)(t),
|
||||||
@@ -79,14 +79,14 @@ func (t *Torrent) UnmarshalJSON(data []byte) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if len(temp.DownloadedIDsJson) > 2 {
|
if len(temp.DownloadedIDsJson) > 2 {
|
||||||
downloadedIDs := strings.Split(string(temp.DownloadedIDsJson), ",")
|
downloadedIDs := strings.Split(strings.ReplaceAll(string(temp.DownloadedIDsJson), `"`, ""), ",")
|
||||||
t.DownloadedIDs = strset.New(downloadedIDs...)
|
t.DownloadedIDs = strset.New(downloadedIDs...)
|
||||||
} else {
|
} else {
|
||||||
t.DownloadedIDs = strset.New()
|
t.DownloadedIDs = strset.New()
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(temp.InProgressIDsJson) > 2 {
|
if len(temp.InProgressIDsJson) > 2 {
|
||||||
inProgressIDs := strings.Split(string(temp.InProgressIDsJson), ",")
|
inProgressIDs := strings.Split(strings.ReplaceAll(string(temp.InProgressIDsJson), `"`, ""), ",")
|
||||||
t.InProgressIDs = strset.New(inProgressIDs...)
|
t.InProgressIDs = strset.New(inProgressIDs...)
|
||||||
} else {
|
} else {
|
||||||
t.InProgressIDs = strset.New()
|
t.InProgressIDs = strset.New()
|
||||||
|
|||||||
Reference in New Issue
Block a user