fix: align direct file serving with CHFS routes

This commit is contained in:
OpenClaw Agent
2026-09-21 20:24:30 +08:00
parent 0a1799ba82
commit 769c7f205e
+4 -13
View File
@@ -564,6 +564,10 @@ func (s *Server) shared(w http.ResponseWriter, r *http.Request) {
_, _ = io.WriteString(w, "</pre>\n")
return
}
if r.Method != http.MethodGet {
http.NotFound(w, r)
return
}
f, err := s.Store.Open(p)
if err != nil {
http.NotFound(w, r)
@@ -611,20 +615,7 @@ func (s *Server) preview(w http.ResponseWriter, r *http.Request) {
}
func (s *Server) fileHandler(w http.ResponseWriter, r *http.Request) {
if r.URL.Path == "/" || strings.HasPrefix(r.URL.Path, "/asset/") {
http.NotFound(w, r)
return
}
if strings.HasPrefix(r.URL.Path, "/chfs/") || r.URL.Path == "/webdav" {
http.NotFound(w, r)
return
}
p := strings.Trim(strings.ReplaceAll(r.URL.Path, "\\", "/"), "/")
if p == "" {
http.NotFound(w, r)
return
}
s.serveFile(w, r, p, false)
}
func (s *Server) serveFile(w http.ResponseWriter, r *http.Request, p string, attachment bool) {