Set verified links cache time to 3 mins

This commit is contained in:
Ben Adrian Sarmiento
2024-08-25 13:30:40 +02:00
parent 11e9c5d431
commit 54230c9eaa
4 changed files with 34 additions and 30 deletions

View File

@@ -378,10 +378,10 @@ func (t *TorrentManager) deleteInfoFile(torrentID string) {
func (t *TorrentManager) mountNewDownloads() {
token := t.Config.GetToken()
tokenMap, _ := t.rd.UnrestrictMap.Get(token)
unrestrictCache, _ := t.rd.UnrestrictCache.Get(token)
// clear maps
tokenMap.Clear()
unrestrictCache.Clear()
t.DownloadMap.Clear()
downloads := t.rd.GetDownloads()
@@ -391,7 +391,7 @@ func (t *TorrentManager) mountNewDownloads() {
if strings.HasPrefix(downloads[i].Link, "https://real-debrid.com/d/") {
downloads[i].Link = downloads[i].Link[0:39]
tokenMap.Set(downloads[i].Link, &downloads[i])
unrestrictCache.Set(downloads[i].Link, &downloads[i])
continue
}

View File

@@ -19,7 +19,7 @@ const (
EXPIRED_LINK_TOLERANCE_HOURS = 24
)
// StartRepairJob is a permanent job that runs every periodically to repair broken torrents
// StartRepairJob is a permanent job that runs periodically to repair broken torrents
func (t *TorrentManager) StartRepairJob() {
if !t.Config.EnableRepair() {
t.repairLog.Warn("Repair is disabled, skipping repair job")
@@ -29,7 +29,6 @@ func (t *TorrentManager) StartRepairJob() {
t.RepairQueue = mapset.NewSet[*Torrent]()
t.RepairAllTrigger = make(chan struct{})
// periodic repair worker
t.workerPool.Submit(func() {
t.repairLog.Debug("Starting periodic repair job")
repairTicker := time.NewTicker(time.Duration(t.Config.GetRepairEveryMins()) * time.Minute)
@@ -48,6 +47,7 @@ func (t *TorrentManager) StartRepairJob() {
}
// EnqueueForRepair allows an on-demand repair to be initiated.
// if torrent is nil, all torrents will be repaired
func (t *TorrentManager) EnqueueForRepair(torrent *Torrent) {
if !t.Config.EnableRepair() {
if torrent != nil {

View File

@@ -167,8 +167,8 @@ func (dl *Downloader) DownloadLink(
}
func (dl *Downloader) streamFileToResponse(
torrent *intTor.Torrent,
file *intTor.File,
torrent *intTor.Torrent, // can be nil if downloading a link
file *intTor.File, // can be nil if downloading a link
unrestrict *realdebrid.Download,
resp http.ResponseWriter,
req *http.Request,