Fix http mount issues

This commit is contained in:
Ben Sarmiento
2024-01-09 00:24:53 +01:00
parent 6c4c73a5b0
commit eb3f2785ce
4 changed files with 36 additions and 9 deletions

View File

@@ -100,8 +100,15 @@ func ServeDownloadsList(torMgr *torrent.TorrentManager) ([]byte, error) {
return buf.Bytes(), nil
}
buf.WriteString("<ol>")
for _, download := range torMgr.DownloadCache.Items() {
buf.WriteString(fmt.Sprintf("<li><a href=\"%s\">%s</a></li>", download.Download, download.Filename))
filenames := torMgr.DownloadMap.Keys()
sort.Strings(filenames)
for _, filename := range filenames {
download, ok := torMgr.DownloadMap.Get(filename)
if !ok || !strings.HasPrefix(download.Link, "http") {
continue
}
filePath := filepath.Join(config.DOWNLOADS, url.PathEscape(filename))
buf.WriteString(fmt.Sprintf("<li><a href=\"/http/%s\">%s</a></li>", filePath, download.Filename))
}
return buf.Bytes(), nil
}