Last batch of optimizations
This commit is contained in:
@@ -9,13 +9,12 @@ import (
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/debridmediamanager.com/zurg/internal/config"
|
||||
"github.com/debridmediamanager.com/zurg/internal/torrent"
|
||||
"github.com/debridmediamanager.com/zurg/pkg/dav"
|
||||
"github.com/debridmediamanager.com/zurg/pkg/logutil"
|
||||
)
|
||||
|
||||
func HandlePropfindRequest(w http.ResponseWriter, r *http.Request, t *torrent.TorrentManager, c config.ConfigInterface) {
|
||||
func HandlePropfindRequest(w http.ResponseWriter, r *http.Request, t *torrent.TorrentManager) {
|
||||
log := logutil.NewLogger().Named("dav")
|
||||
|
||||
requestPath := path.Clean(r.URL.Path)
|
||||
@@ -28,7 +27,7 @@ func HandlePropfindRequest(w http.ResponseWriter, r *http.Request, t *torrent.To
|
||||
|
||||
switch {
|
||||
case len(filteredSegments) == 1 && filteredSegments[0] == "":
|
||||
output, err = handleRoot(c)
|
||||
output, err = handleRoot(t)
|
||||
case len(filteredSegments) == 1:
|
||||
output, err = handleListOfTorrents(requestPath, t)
|
||||
case len(filteredSegments) == 2:
|
||||
@@ -57,10 +56,13 @@ func HandlePropfindRequest(w http.ResponseWriter, r *http.Request, t *torrent.To
|
||||
}
|
||||
}
|
||||
|
||||
func handleRoot(c config.ConfigInterface) ([]byte, error) {
|
||||
func handleRoot(t *torrent.TorrentManager) ([]byte, error) {
|
||||
var responses []dav.Response
|
||||
responses = append(responses, dav.Directory(""))
|
||||
for _, directory := range c.GetDirectories() {
|
||||
|
||||
directories := t.DirectoryMap.Keys()
|
||||
sort.Strings(directories)
|
||||
for _, directory := range directories {
|
||||
responses = append(responses, dav.Directory(directory))
|
||||
}
|
||||
rootResponse := dav.MultiStatus{
|
||||
|
||||
Reference in New Issue
Block a user