mirror of https://github.com/Xhofe/alist
fix(search): missed base_path of user for parent (close #2611)
parent
7aa4dfb240
commit
e65e8be59e
|
@ -20,8 +20,17 @@ type SearchResp struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func Search(c *gin.Context) {
|
func Search(c *gin.Context) {
|
||||||
var req model.SearchReq
|
var (
|
||||||
if err := c.ShouldBind(&req); err != nil {
|
req model.SearchReq
|
||||||
|
err error
|
||||||
|
)
|
||||||
|
if err = c.ShouldBind(&req); err != nil {
|
||||||
|
common.ErrorResp(c, err, 400)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
user := c.MustGet("user").(*model.User)
|
||||||
|
req.Parent, err = user.JoinPath(req.Parent)
|
||||||
|
if err != nil {
|
||||||
common.ErrorResp(c, err, 400)
|
common.ErrorResp(c, err, 400)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -34,8 +43,7 @@ func Search(c *gin.Context) {
|
||||||
common.ErrorResp(c, err, 500)
|
common.ErrorResp(c, err, 500)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
filteredNodes := []model.SearchNode{}
|
var filteredNodes []model.SearchNode
|
||||||
user := c.MustGet("user").(*model.User)
|
|
||||||
for _, node := range nodes {
|
for _, node := range nodes {
|
||||||
if !strings.HasPrefix(node.Parent, user.BasePath) {
|
if !strings.HasPrefix(node.Parent, user.BasePath) {
|
||||||
continue
|
continue
|
||||||
|
@ -47,7 +55,6 @@ func Search(c *gin.Context) {
|
||||||
if !common.CanAccess(user, meta, path.Join(node.Parent, node.Name), "") {
|
if !common.CanAccess(user, meta, path.Join(node.Parent, node.Name), "") {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
// node.Parent = "/" + strings.Replace(node.Parent, user.BasePath, "", 1)
|
|
||||||
filteredNodes = append(filteredNodes, node)
|
filteredNodes = append(filteredNodes, node)
|
||||||
}
|
}
|
||||||
common.SuccessResp(c, common.PageResp{
|
common.SuccessResp(c, common.PageResp{
|
||||||
|
|
Loading…
Reference in New Issue