diff --git a/internal/fs/list.go b/internal/fs/list.go index 103e668245f..a0aa2b884be 100644 --- a/internal/fs/list.go +++ b/internal/fs/list.go @@ -59,7 +59,7 @@ func whetherHide(user *model.User, meta *model.Meta, path string) bool { return false } // if meta doesn't apply to sub_folder, don't hide - if !utils.PathEqual(meta.Path, path) && !meta.SubFolder { + if !utils.PathEqual(meta.Path, path) && !meta.HSub { return false } // if is guest, hide diff --git a/internal/model/meta.go b/internal/model/meta.go index 45ad8fedfca..afbdb63fcd7 100644 --- a/internal/model/meta.go +++ b/internal/model/meta.go @@ -1,11 +1,14 @@ package model type Meta struct { - ID uint `json:"id" gorm:"primaryKey"` - Path string `json:"path" gorm:"unique" binding:"required"` - Password string `json:"password"` - Write bool `json:"upload"` - Hide string `json:"hide"` - SubFolder bool `json:"sub_folder"` - Readme string `json:"readme"` + ID uint `json:"id" gorm:"primaryKey"` + Path string `json:"path" gorm:"unique" binding:"required"` + Password string `json:"password"` + PSub bool `json:"p_sub"` + Write bool `json:"write"` + WSub bool `json:"w_sub"` + Hide string `json:"hide"` + HSub bool `json:"h_sub"` + Readme string `json:"readme"` + RSub bool `json:"r_sub"` } diff --git a/server/controllers/fsmanage.go b/server/controllers/fsmanage.go index 5ab9dfe034a..1cfd40f312f 100644 --- a/server/controllers/fsmanage.go +++ b/server/controllers/fsmanage.go @@ -48,7 +48,7 @@ func canMkdirOrPut(meta *model.Meta, path string) bool { if meta == nil || !meta.Write { return false } - return meta.SubFolder || meta.Path == path + return meta.WSub || meta.Path == path } type MoveCopyReq struct { diff --git a/server/controllers/fsread.go b/server/controllers/fsread.go index 7bdcf5210e0..42a1a3d095b 100644 --- a/server/controllers/fsread.go +++ b/server/controllers/fsread.go @@ -34,6 +34,7 @@ type ObjResp struct { type FsListResp struct { Content []ObjResp `json:"content"` Total int64 `json:"total"` + Readme string `json:"readme"` } func FsList(c *gin.Context) { @@ -66,9 +67,17 @@ func FsList(c *gin.Context) { common.SuccessResp(c, FsListResp{ Content: toObjResp(objs), Total: int64(total), + Readme: getReadme(meta, req.Path), }) } +func getReadme(meta *model.Meta, path string) string { + if meta != nil && (utils.PathEqual(meta.Path, path) || meta.RSub) { + return meta.Readme + } + return "" +} + func canAccess(user *model.User, meta *model.Meta, path string, password string) bool { // if is not guest, can access if user.CanAccessWithoutPassword() { @@ -79,7 +88,7 @@ func canAccess(user *model.User, meta *model.Meta, path string, password string) return true } // if meta doesn't apply to sub_folder, can access - if !utils.PathEqual(meta.Path, path) && !meta.SubFolder { + if !utils.PathEqual(meta.Path, path) && !meta.PSub { return true } // validate password diff --git a/server/middlewares/down.go b/server/middlewares/down.go index ef1583e0681..f49fd30e140 100644 --- a/server/middlewares/down.go +++ b/server/middlewares/down.go @@ -47,7 +47,7 @@ func needSign(meta *model.Meta, path string) bool { if meta == nil || meta.Password == "" { return false } - if !meta.SubFolder && path != meta.Path { + if !meta.PSub && path != meta.Path { return false } return true