Remove download mount config, it is now always enabled
This commit is contained in:
@@ -30,9 +30,8 @@ type TorrentManager struct {
|
||||
log *logutil.Logger
|
||||
repairLog *logutil.Logger
|
||||
|
||||
DirectoryMap cmap.ConcurrentMap[string, cmap.ConcurrentMap[string, *Torrent]] // directory -> accessKey -> Torrent
|
||||
DownloadMap cmap.ConcurrentMap[string, *realdebrid.Download]
|
||||
DownloadCache cmap.ConcurrentMap[string, *realdebrid.Download]
|
||||
DirectoryMap cmap.ConcurrentMap[string, cmap.ConcurrentMap[string, *Torrent]] // directory -> accessKey -> Torrent
|
||||
DownloadMap cmap.ConcurrentMap[string, *realdebrid.Download]
|
||||
|
||||
RootNode *fs.FileNode
|
||||
|
||||
@@ -64,9 +63,8 @@ func NewTorrentManager(cfg config.ConfigInterface, api *realdebrid.RealDebrid, w
|
||||
log: log,
|
||||
repairLog: repairLog,
|
||||
|
||||
DirectoryMap: cmap.New[cmap.ConcurrentMap[string, *Torrent]](),
|
||||
DownloadMap: cmap.New[*realdebrid.Download](),
|
||||
DownloadCache: cmap.New[*realdebrid.Download](),
|
||||
DirectoryMap: cmap.New[cmap.ConcurrentMap[string, *Torrent]](),
|
||||
DownloadMap: cmap.New[*realdebrid.Download](),
|
||||
|
||||
RootNode: fs.NewFileNode("root", true),
|
||||
|
||||
@@ -96,19 +94,17 @@ func NewTorrentManager(cfg config.ConfigInterface, api *realdebrid.RealDebrid, w
|
||||
|
||||
// proxy function
|
||||
func (t *TorrentManager) UnrestrictLinkUntilOk(link string) *realdebrid.Download {
|
||||
if strings.HasPrefix(link, "https://real-debrid.com/d/") && t.DownloadCache.Has(link[0:39]) {
|
||||
ret, _ := t.DownloadCache.Get(link[0:39])
|
||||
if strings.HasPrefix(link, "https://real-debrid.com/d/") && t.DownloadMap.Has(link[0:39]) {
|
||||
ret, _ := t.DownloadMap.Get(link[0:39])
|
||||
return ret
|
||||
}
|
||||
ret, err := t.api.UnrestrictLink(link, t.Config.ShouldServeFromRclone())
|
||||
t.DownloadCache.Set(ret.Link[0:39], ret)
|
||||
t.DownloadMap.Set(ret.Link[0:39], ret)
|
||||
if err != nil {
|
||||
t.log.Warnf("Cannot unrestrict link %s: %v", link, err)
|
||||
return nil
|
||||
}
|
||||
if t.Config.EnableDownloadMount() {
|
||||
t.DownloadMap.Set(ret.Filename, ret)
|
||||
}
|
||||
t.DownloadMap.Set(ret.Filename, ret)
|
||||
return ret
|
||||
}
|
||||
|
||||
@@ -273,22 +269,11 @@ func (t *TorrentManager) deleteInfoFile(torrentID string) {
|
||||
/// end info functions
|
||||
|
||||
func (t *TorrentManager) mountDownloads() {
|
||||
if !t.Config.EnableDownloadMount() {
|
||||
return
|
||||
}
|
||||
t.DownloadMap.Clear()
|
||||
t.DownloadCache.Clear()
|
||||
_ = t.workerPool.Submit(func() {
|
||||
downloads, totalDownloads, err := t.api.GetDownloads()
|
||||
if err != nil {
|
||||
t.log.Errorf("Cannot get downloads: %v", err)
|
||||
}
|
||||
t.log.Debugf("Got %d downloads", totalDownloads)
|
||||
downloads := t.api.GetDownloads()
|
||||
for i := range downloads {
|
||||
idx := i
|
||||
if strings.HasPrefix(downloads[idx].Link, "https://real-debrid.com/d/") {
|
||||
t.DownloadCache.Set(downloads[idx].Link[0:39], &downloads[idx])
|
||||
}
|
||||
t.DownloadMap.Set(downloads[idx].Filename, &downloads[idx])
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user