- Cleaup the code
- Add delete button to webdav ui - Some other bug fixes here and there
This commit is contained in:
@@ -1,11 +1,9 @@
|
||||
package webdav
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
// getName: Returns the torrent name and filename from the path
|
||||
@@ -18,27 +16,12 @@ func getName(rootDir, path string) (string, string) {
|
||||
return parts[1], strings.Join(parts[2:], string(os.PathSeparator)) // Note the change from [0] to [1]
|
||||
}
|
||||
|
||||
func acceptsGzip(r *http.Request) bool {
|
||||
return strings.Contains(r.Header.Get("Accept-Encoding"), "gzip")
|
||||
}
|
||||
|
||||
func isValidURL(str string) bool {
|
||||
u, err := url.Parse(str)
|
||||
// A valid URL should parse without error, and have a non-empty scheme and host.
|
||||
return err == nil && u.Scheme != "" && u.Host != ""
|
||||
}
|
||||
|
||||
// Determine TTL based on the requested folder:
|
||||
// - If the path is exactly the parent folder (which changes frequently),
|
||||
// use a short TTL.
|
||||
// - Otherwise, for deeper (torrent folder) paths, use a longer TTL.
|
||||
func (h *Handler) getCacheTTL(urlPath string) time.Duration {
|
||||
if _, ok := h.isParentPath(urlPath); ok {
|
||||
return 30 * time.Second // Short TTL for parent folders
|
||||
}
|
||||
return 2 * time.Minute // Longer TTL for other paths
|
||||
}
|
||||
|
||||
var pctHex = "0123456789ABCDEF"
|
||||
|
||||
// fastEscapePath returns a percent-encoded path, preserving '/'
|
||||
|
||||
Reference in New Issue
Block a user