feat: customize ignore paths of indexes

This commit is contained in:
Noah Hsu
2022-12-05 16:45:11 +08:00
parent bd33c200dc
commit bf8b6f4c2c
7 changed files with 120 additions and 89 deletions

View File

@ -25,6 +25,12 @@ func BuildIndex(c *gin.Context) {
common.ErrorStrResp(c, "index is running", 400)
return
}
ignorePaths, err := search.GetIgnorePaths()
if err != nil {
common.ErrorResp(c, err, 500)
return
}
ignorePaths = append(ignorePaths, req.IgnorePaths...)
go func() {
ctx := context.Background()
err := search.Clear(ctx)
@ -32,7 +38,7 @@ func BuildIndex(c *gin.Context) {
log.Errorf("clear index error: %+v", err)
return
}
err = search.BuildIndex(context.Background(), req.Paths, req.IgnorePaths, req.MaxDepth, true)
err = search.BuildIndex(context.Background(), req.Paths, ignorePaths, req.MaxDepth, true)
if err != nil {
log.Errorf("build index error: %+v", err)
}