feat: implement multi-root virtual filesystem
This commit is contained in:
@@ -24,6 +24,7 @@ type Server struct {
|
||||
Sessions map[string]*auth.Account
|
||||
WebDAVRoot string
|
||||
Allow string
|
||||
MultiRoot bool
|
||||
}
|
||||
type fileInfo struct {
|
||||
Name string `json:"name"`
|
||||
@@ -74,13 +75,13 @@ func qpath(r *http.Request) string {
|
||||
}
|
||||
func permString(p auth.PermMask) string {
|
||||
if p.HasDelete() {
|
||||
return "d"
|
||||
return "RWD"
|
||||
}
|
||||
if p.HasWrite() {
|
||||
return "w"
|
||||
return "RW"
|
||||
}
|
||||
if p.HasRead() {
|
||||
return "r"
|
||||
return "R"
|
||||
}
|
||||
return ""
|
||||
}
|
||||
@@ -106,9 +107,10 @@ func (s *Server) files(w http.ResponseWriter, r *http.Request) {
|
||||
sub = len(xs) > 0
|
||||
}
|
||||
}
|
||||
out = append(out, fileInfo{Name: fi.Name(), Path: fp, Size: fi.Size(), Modified: fi.ModTime().Format(time.RFC3339), Dir: fi.IsDir(), Mask: permString(a.MaskFor(fp)), HasSubDir: sub})
|
||||
out = append(out, fileInfo{Name: fi.Name(), Path: fp, Size: fi.Size(), Modified: fi.ModTime().Format(time.RFC3339), Dir: fi.IsDir(), Mask: permString(a.MaskFor(fp)), GuestMask: permString(s.Auth.Guest.MaskFor(fp)), HasSubDir: sub})
|
||||
}
|
||||
writeJSON(w, map[string]any{"files": out, "currentMask": permString(m), "virtualRoot": false})
|
||||
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) {
|
||||
_ = r.ParseMultipartForm(16 << 20)
|
||||
|
||||
Reference in New Issue
Block a user