feat: add readme field to list resp
This commit is contained in:
@ -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 {
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user