fix: match CHFS file API response types
This commit is contained in:
@@ -45,7 +45,6 @@ type Server struct {
|
||||
}
|
||||
type fileInfo struct {
|
||||
Name string `json:"name"`
|
||||
Path string `json:"path"`
|
||||
Size int64 `json:"size"`
|
||||
Modified string `json:"modified"`
|
||||
Dir bool `json:"dir"`
|
||||
@@ -170,7 +169,7 @@ func (s *Server) files(w http.ResponseWriter, r *http.Request) {
|
||||
if !m.HasRead() {
|
||||
// CHFS keeps the files endpoint HTTP-successful for a denied directory
|
||||
// and returns an empty listing with currentMask="".
|
||||
writeJSON(w, map[string]any{"files": []fileInfo{}, "currentMask": "", "virtualRoot": false})
|
||||
writeJSON(w, map[string]any{"files": []fileInfo{}, "currentMask": "", "virtualRoot": 0})
|
||||
return
|
||||
}
|
||||
list, e := s.Store.List(p)
|
||||
@@ -197,9 +196,12 @@ func (s *Server) files(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
}
|
||||
}
|
||||
out = append(out, fileInfo{Name: fi.Name(), Path: fp, Size: fi.Size(), Modified: originalTime(fi.ModTime()), Dir: fi.IsDir(), Mask: permString(a.MaskForEntry(fp)), GuestMask: permString(s.Auth.Guest.MaskForEntry(fp)), HasSubDir: sub, Icon: iconFor(fi)})
|
||||
out = append(out, fileInfo{Name: fi.Name(), Size: fi.Size(), Modified: originalTime(fi.ModTime()), Dir: fi.IsDir(), Mask: permString(a.MaskForEntry(fp)), GuestMask: permString(s.Auth.Guest.MaskForEntry(fp)), HasSubDir: sub, Icon: iconFor(fi)})
|
||||
}
|
||||
virtual := 0
|
||||
if p == "" && s.MultiRoot {
|
||||
virtual = 1
|
||||
}
|
||||
virtual := p == "" && s.MultiRoot
|
||||
writeJSON(w, map[string]any{"files": out, "currentMask": permString(m), "virtualRoot": virtual})
|
||||
}
|
||||
func (s *Server) newdir(w http.ResponseWriter, r *http.Request) {
|
||||
@@ -490,7 +492,7 @@ func (s *Server) search(w http.ResponseWriter, r *http.Request) {
|
||||
continue
|
||||
}
|
||||
if needle == "" || strings.Contains(strings.ToLower(fi.Name()), needle) {
|
||||
out = append(out, fileInfo{Name: fi.Name(), Path: "/" + strings.Trim(p, "/"), Size: fi.Size(), Modified: originalTime(fi.ModTime()), Dir: fi.IsDir(), Mask: permString(a.MaskForEntry(p)), GuestMask: permString(s.Auth.Guest.MaskForEntry(p)), HasSubDir: false, Icon: iconFor(fi)})
|
||||
out = append(out, fileInfo{Name: fi.Name(), Size: fi.Size(), Modified: originalTime(fi.ModTime()), Dir: fi.IsDir(), Mask: permString(a.MaskForEntry(p)), GuestMask: permString(s.Auth.Guest.MaskForEntry(p)), HasSubDir: false, Icon: iconFor(fi)})
|
||||
}
|
||||
if fi.IsDir() {
|
||||
if err := walk(p); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user