diff --git a/internal/torrent/manager.go b/internal/torrent/manager.go index 4047919..6a6ec48 100644 --- a/internal/torrent/manager.go +++ b/internal/torrent/manager.go @@ -25,7 +25,6 @@ type TorrentManager struct { Config config.ConfigInterface Api *realdebrid.RealDebrid DirectoryMap cmap.ConcurrentMap[string, cmap.ConcurrentMap[string, *Torrent]] // directory -> accessKey -> Torrent - DownloadCache cmap.ConcurrentMap[string, *realdebrid.Download] DownloadMap cmap.ConcurrentMap[string, *realdebrid.Download] fixers cmap.ConcurrentMap[string, string] // trigger -> [command, id] allAccessKeys mapset.Set[string] @@ -51,7 +50,6 @@ func NewTorrentManager(cfg config.ConfigInterface, api *realdebrid.RealDebrid, w Config: cfg, Api: api, DirectoryMap: cmap.New[cmap.ConcurrentMap[string, *Torrent]](), - DownloadCache: cmap.New[*realdebrid.Download](), RefreshKillSwitch: make(chan struct{}, 1), RepairKillSwitch: make(chan struct{}, 1), RemountTrigger: make(chan struct{}, 1), @@ -82,20 +80,12 @@ func NewTorrentManager(cfg config.ConfigInterface, api *realdebrid.RealDebrid, w // proxy func (t *TorrentManager) UnrestrictLinkUntilOk(link string) *realdebrid.Download { - // check if it's a valid link - if !strings.HasPrefix(link, "http") { - return nil - } - if download, exists := t.DownloadCache.Get(link); exists { - return download - } ret, err := t.Api.UnrestrictLink(link, t.Config.ShouldServeFromRclone()) if err != nil { t.log.Warnf("Cannot unrestrict link %s: %v", link, err) return nil } if ret != nil && ret.Link != "" && ret.Filename != "" { - t.DownloadCache.Set(ret.Link, ret) if t.Config.EnableDownloadMount() { t.DownloadMap.Set(ret.Filename, ret) } @@ -199,7 +189,7 @@ func (t *TorrentManager) mountDownloads() { if !t.Config.EnableDownloadMount() { return } - t.DownloadMap = cmap.New[*realdebrid.Download]() + t.DownloadMap.Clear() _ = t.workerPool.Submit(func() { page := 1 offset := 0 diff --git a/pkg/realdebrid/api.go b/pkg/realdebrid/api.go index 5cc73c4..f212b36 100644 --- a/pkg/realdebrid/api.go +++ b/pkg/realdebrid/api.go @@ -92,11 +92,6 @@ func (rd *RealDebrid) UnrestrictLink(link string, checkFirstByte bool) (*Downloa } defer resp.Body.Close() - if resp.StatusCode != http.StatusOK { - rd.log.Errorf("Unrestrict link request returned status code %d for link %s", resp.StatusCode, link) - // return nil, fmt.Errorf("unrestrict link request returned status code %d", resp.StatusCode) - } - body, err := io.ReadAll(resp.Body) if err != nil { // rd.log.Errorf("Error when reading the body of unrestrict link response: %v", err) @@ -433,10 +428,6 @@ func (rd *RealDebrid) AvailabilityCheck(hashes []string) (AvailabilityResponse, } defer resp.Body.Close() - if resp.StatusCode != http.StatusOK { - return nil, fmt.Errorf("error, got response status code %d", resp.StatusCode) - } - var response AvailabilityResponse err = json.NewDecoder(resp.Body).Decode(&response) if err != nil {