diff --git a/internal/search/build.go b/internal/search/build.go index a806d08fadb..1d3bfb7cd5d 100644 --- a/internal/search/build.go +++ b/internal/search/build.go @@ -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}, diff --git a/server/handles/index.go b/server/handles/index.go index 4e8babd209f..0fa1fa0e9bf 100644 --- a/server/handles/index.go +++ b/server/handles/index.go @@ -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()