Remove download cache
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user