From 52b400c7932308a8a39b082100a213d18da3267d Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Tue, 16 Jan 2024 21:42:34 +0800 Subject: [PATCH] :art: Prevent syncMergeResult push nil --- kernel/model/sync.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/kernel/model/sync.go b/kernel/model/sync.go index 20be7c92e..a8c041462 100644 --- a/kernel/model/sync.go +++ b/kernel/model/sync.go @@ -279,6 +279,13 @@ func incReindex(upserts, removes []string) (upsertRootIDs, removeRootIDs []strin util.IncBootProgress(3, "Sync reindexing...") removeRootIDs = removeIndexes(removes) // 先执行 remove,否则移动文档时 upsert 会被忽略,导致未被索引 upsertRootIDs = upsertIndexes(upserts) + + if 1 > len(removeRootIDs) { + removeRootIDs = []string{} + } + if 1 > len(upsertRootIDs) { + upsertRootIDs = []string{} + } return } @@ -301,6 +308,10 @@ func removeIndexes(removeFilePaths []string) (removeRootIDs []string) { sql.RemoveTreeQueue(block.BoxID, block.RootID) } } + + if 1 > len(removeRootIDs) { + removeRootIDs = []string{} + } return } @@ -336,6 +347,10 @@ func upsertIndexes(upsertFilePaths []string) (upsertRootIDs []string) { sql.UpsertTreeQueue(tree) upsertRootIDs = append(upsertRootIDs, tree.Root.ID) } + + if 1 > len(upsertRootIDs) { + upsertRootIDs = []string{} + } return }