diff --git a/internal/dav/infuse.go b/internal/dav/infuse.go
index c216c4f..9dfd6a4 100644
--- a/internal/dav/infuse.go
+++ b/internal/dav/infuse.go
@@ -100,7 +100,13 @@ func ServeDownloadsListForInfuse(torMgr *torrent.TorrentManager) ([]byte, error)
return buf.Bytes(), nil
}
buf.WriteString("")
- for _, download := range torMgr.DownloadCache.Items() {
+ 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
+ }
buf.WriteString(dav.File(download.Filename, download.Filesize, download.Generated))
}
buf.WriteString("")
diff --git a/internal/dav/listing.go b/internal/dav/listing.go
index 181c565..ce340d6 100644
--- a/internal/dav/listing.go
+++ b/internal/dav/listing.go
@@ -127,7 +127,13 @@ func ServeDownloadsList(torMgr *torrent.TorrentManager) ([]byte, error) {
}
buf.WriteString("")
buf.WriteString(dav.BaseDirectory(config.DOWNLOADS, ""))
- for _, download := range torMgr.DownloadCache.Items() {
+ 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
+ }
buf.WriteString(dav.File(download.Filename, download.Filesize, download.Generated))
}
buf.WriteString("")
diff --git a/internal/handlers/home.go b/internal/handlers/home.go
index 7c88179..657d4b5 100644
--- a/internal/handlers/home.go
+++ b/internal/handlers/home.go
@@ -21,8 +21,9 @@ type RootResponse struct {
Version string `json:"version"`
BuiltAt string `json:"built_at"`
GitCommit string `json:"git_commit"`
- Dav string `json:"dav"`
Html string `json:"html"`
+ Dav string `json:"dav"`
+ Infuse string `json:"infuse"`
Logs string `json:"logs"`
UserInfo *realdebrid.User `json:"user_info"` // Replace UserInfoType with the actual type
MemAlloc uint64 `json:"mem_alloc"` // Memory allocation in MB
@@ -48,8 +49,9 @@ func (zr *Handlers) handleHome(resp http.ResponseWriter, req *http.Request) {
Version: version.GetVersion(),
BuiltAt: version.GetBuiltAt(),
GitCommit: version.GetGitCommit(),
- Dav: fmt.Sprintf("//%s/dav/", req.Host),
Html: fmt.Sprintf("//%s/http/", req.Host),
+ Dav: fmt.Sprintf("//%s/dav/", req.Host),
+ Infuse: fmt.Sprintf("//%s/infuse/", req.Host),
Logs: fmt.Sprintf("//%s/logs/", req.Host),
UserInfo: userInfo,
MemAlloc: bToMb(mem.Alloc),
@@ -81,12 +83,16 @@ func (zr *Handlers) handleHome(resp http.ResponseWriter, req *http.Request) {
Git Commit |
%s |
+
+ | HTML |
+ %s |
+
| DAV |
%s |
- | HTML |
+ Infuse |
%s |
@@ -238,10 +244,12 @@ func (zr *Handlers) handleHome(resp http.ResponseWriter, req *http.Request) {
response.Version,
response.BuiltAt,
response.GitCommit,
- response.Dav,
- response.Dav,
response.Html,
response.Html,
+ response.Dav,
+ response.Dav,
+ response.Infuse,
+ response.Infuse,
response.Logs,
response.Logs,
response.MemAlloc,
diff --git a/internal/http/listing.go b/internal/http/listing.go
index bc8b2dd..915a5c3 100644
--- a/internal/http/listing.go
+++ b/internal/http/listing.go
@@ -100,8 +100,15 @@ func ServeDownloadsList(torMgr *torrent.TorrentManager) ([]byte, error) {
return buf.Bytes(), nil
}
buf.WriteString("")
- for _, download := range torMgr.DownloadCache.Items() {
- buf.WriteString(fmt.Sprintf("- %s
", 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("- %s
", filePath, download.Filename))
}
return buf.Bytes(), nil
}