Skip to content

Commit

Permalink
fix(search): duplicate folder on autoupdate (#6063 close #6062)
Browse files Browse the repository at this point in the history
* fix(search): the problem of not returning in time when index does not support auto update.

* fix(search): the problem of duplicate indexing of folders.
  • Loading branch information
r27153733 authored Feb 20, 2024
1 parent 47f4b05 commit 53926d5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
17 changes: 9 additions & 8 deletions internal/search/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,14 +211,15 @@ func Update(parent string, objs []model.Obj) {
}
for i := range objs {
if toAdd.Contains(objs[i].GetName()) {
log.Debugf("add index: %s", path.Join(parent, objs[i].GetName()))
err = Index(ctx, parent, objs[i])
if err != nil {
log.Errorf("update search index error while index new node: %+v", err)
return
}
// build index if it's a folder
if objs[i].IsDir() {
if !objs[i].IsDir() {
log.Debugf("add index: %s", path.Join(parent, objs[i].GetName()))
err = Index(ctx, parent, objs[i])
if err != nil {
log.Errorf("update search index error while index new node: %+v", err)
return
}
} else {
// build index if it's a folder
dir := path.Join(parent, objs[i].GetName())
err = BuildIndex(ctx,
[]string{dir},
Expand Down
1 change: 1 addition & 0 deletions server/handles/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ func UpdateIndex(c *gin.Context) {
}
if !search.Config(c).AutoUpdate {
common.ErrorStrResp(c, "update is not supported for current index", 400)
return
}
go func() {
ctx := context.Background()
Expand Down

0 comments on commit 53926d5

Please sign in to comment.