Readd downloads mount
This commit is contained in:
@@ -2,7 +2,6 @@ package torrent
|
||||
|
||||
import (
|
||||
"io"
|
||||
"net/url"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
@@ -68,7 +67,7 @@ func NewTorrentManager(cfg config.ConfigInterface, api *realdebrid.RealDebrid, w
|
||||
}
|
||||
|
||||
// Fetch downloads
|
||||
if t.Config.EnableDownloadCache() {
|
||||
if t.Config.EnableDownloadMount() {
|
||||
_ = t.workerPool.Submit(func() {
|
||||
page := 1
|
||||
offset := 0
|
||||
@@ -78,7 +77,7 @@ func NewTorrentManager(cfg config.ConfigInterface, api *realdebrid.RealDebrid, w
|
||||
t.log.Fatalf("Cannot get downloads: %v", err)
|
||||
}
|
||||
for i := range downloads {
|
||||
t.cacheDownload(&downloads[i])
|
||||
t.DownloadMap.Set(downloads[i].Filename, &downloads[i])
|
||||
}
|
||||
offset += len(downloads)
|
||||
page++
|
||||
@@ -122,7 +121,8 @@ func (t *TorrentManager) UnrestrictUntilOk(link string) *realdebrid.Download {
|
||||
return nil
|
||||
}
|
||||
if ret != nil && ret.Link != "" && ret.Filename != "" {
|
||||
t.cacheDownload(ret)
|
||||
t.DownloadCache.Set(ret.Link, ret)
|
||||
t.DownloadMap.Set(ret.Filename, ret)
|
||||
}
|
||||
return ret
|
||||
}
|
||||
@@ -242,17 +242,3 @@ func (t *TorrentManager) deleteTorrentFile(torrentID string) {
|
||||
t.log.Warnf("Cannot delete file %s: %v", filePath, err)
|
||||
}
|
||||
}
|
||||
|
||||
func replaceHostInURL(inputURL string, newHost string) string {
|
||||
u, err := url.Parse(inputURL)
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
u.Host = newHost
|
||||
return u.String()
|
||||
}
|
||||
|
||||
func (t *TorrentManager) cacheDownload(ret *realdebrid.Download) {
|
||||
t.DownloadCache.Set(ret.Link, ret)
|
||||
t.DownloadMap.Set(ret.Filename, ret)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user