mirror of https://github.com/Xhofe/alist
fix: allow force root while fetch dirs (close #1671)
parent
b197322cd8
commit
66b2562d03
|
@ -28,6 +28,7 @@ type ListReq struct {
|
||||||
type DirReq struct {
|
type DirReq struct {
|
||||||
Path string `json:"path" form:"path"`
|
Path string `json:"path" form:"path"`
|
||||||
Password string `json:"password" form:"password"`
|
Password string `json:"password" form:"password"`
|
||||||
|
ForceRoot bool `json:"force_root" form:"force_root"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ObjResp struct {
|
type ObjResp struct {
|
||||||
|
@ -93,7 +94,14 @@ func FsDirs(c *gin.Context) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
user := c.MustGet("user").(*model.User)
|
user := c.MustGet("user").(*model.User)
|
||||||
|
if req.ForceRoot {
|
||||||
|
if !user.IsAdmin() {
|
||||||
|
common.ErrorStrResp(c, "Permission denied", 403)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
} else {
|
||||||
req.Path = stdpath.Join(user.BasePath, req.Path)
|
req.Path = stdpath.Join(user.BasePath, req.Path)
|
||||||
|
}
|
||||||
meta, err := db.GetNearestMeta(req.Path)
|
meta, err := db.GetNearestMeta(req.Path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !errors.Is(errors.Cause(err), errs.MetaNotFound) {
|
if !errors.Is(errors.Cause(err), errs.MetaNotFound) {
|
||||||
|
|
Loading…
Reference in New Issue