Use new router

This commit is contained in:
Ben Sarmiento
2023-11-30 22:46:29 +01:00
parent 5472f7d08d
commit 0ad879066e
13 changed files with 311 additions and 384 deletions

View File

@@ -67,26 +67,26 @@ func NewTorrentManager(cfg config.ConfigInterface, api *realdebrid.RealDebrid, p
// Fetch downloads
t.DownloadCache = cmap.New[*realdebrid.Download]()
_ = t.workerPool.Submit(func() {
page := 1
offset := 0
for {
downloads, totalDownloads, err := t.Api.GetDownloads(page, offset)
if err != nil {
t.log.Fatalf("Cannot get downloads: %v\n", err)
}
for i := range downloads {
if !t.DownloadCache.Has(downloads[i].Link) {
t.DownloadCache.Set(downloads[i].Link, &downloads[i])
}
}
offset += len(downloads)
page++
if offset >= totalDownloads {
break
}
}
})
// _ = t.workerPool.Submit(func() {
// page := 1
// offset := 0
// for {
// downloads, totalDownloads, err := t.Api.GetDownloads(page, offset)
// if err != nil {
// t.log.Fatalf("Cannot get downloads: %v\n", err)
// }
// for i := range downloads {
// if !t.DownloadCache.Has(downloads[i].Link) {
// t.DownloadCache.Set(downloads[i].Link, &downloads[i])
// }
// }
// offset += len(downloads)
// page++
// if offset >= totalDownloads {
// break
// }
// }
// })
var newTorrents []realdebrid.Torrent
var err error
@@ -869,7 +869,7 @@ func (t *TorrentManager) updateDirectoryResponsesCache() {
continue
}
davRet += dav.Directory(tor.AccessKey, tor.LatestAdded)
htmlRet += fmt.Sprintf("<li><a href=\"/http/%s/%s\">%s</a></li>", directory, tor.AccessKey, tor.AccessKey)
htmlRet += fmt.Sprintf("<li><a href=\"/http/%s/%s/\">%s</a></li>", directory, tor.AccessKey, tor.AccessKey)
}
}
@@ -897,7 +897,7 @@ func (t *TorrentManager) buildTorrentResponses(tor *Torrent) (string, string) {
davRet += dav.File(filename, file.Bytes, file.Ended)
filePath := filepath.Join("$dir", tor.AccessKey, url.PathEscape(filename))
htmlRet += fmt.Sprintf("<li><a href=\"%s\">%s</a></li>", filePath, filename)
htmlRet += fmt.Sprintf("<li><a href=\"/http/%s\">%s</a></li>", filePath, filename)
}
davRet += "</d:multistatus>"