An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:bug: Reindex startup sync data before merging https://github.com/siyuan-note/siyuan/issues/18410
Daniel5dcf82db18db
diff --git a/kernel/go.mod b/kernel/go.modindex 5eb2d9cc26..8fd147a504 100644--- a/kernel/go.mod+++ b/kernel/go.mod@@ -70,7 +70,7 @@ require (github.com/sashabaranov/go-openai v1.41.2github.com/shirou/gopsutil/v4 v4.26.6github.com/siyuan-note/dataparser v0.0.0-20260115084335-b57cb8bc7c17- github.com/siyuan-note/dejavu v0.0.0-20260810172624-2515c1cedd81+ github.com/siyuan-note/dejavu v0.0.0-20260811012100-7ebd0ab8260fgithub.com/siyuan-note/encryption v0.0.0-20260715062728-9cb8e9548044github.com/siyuan-note/eventbus v0.0.0-20260530125927-d77c74260dcegithub.com/siyuan-note/filelock v0.0.0-20260411141728-bf44452627c0diff --git a/kernel/go.sum b/kernel/go.sumindex 04de2eb001..17d6250903 100644--- a/kernel/go.sum+++ b/kernel/go.sum@@ -409,6 +409,8 @@ github.com/siyuan-note/dejavu v0.0.0-20260809143958-da62d786c482 h1:WkS4DY2Z1oALgithub.com/siyuan-note/dejavu v0.0.0-20260809143958-da62d786c482/go.mod h1:aTT2bB17VqAhdHHkScfDnMzJf8At3zYwGvTqntjiCwA=github.com/siyuan-note/dejavu v0.0.0-20260810172624-2515c1cedd81 h1:s7CP259xPatSRSumna/fc40ftYR0EtEXNixdpN1dfeM=github.com/siyuan-note/dejavu v0.0.0-20260810172624-2515c1cedd81/go.mod h1:aTT2bB17VqAhdHHkScfDnMzJf8At3zYwGvTqntjiCwA=+github.com/siyuan-note/dejavu v0.0.0-20260811012100-7ebd0ab8260f h1:A1zWCOaIcxCU87V8aE8SF351jccyOB/83E8MGlXBbdU=+github.com/siyuan-note/dejavu v0.0.0-20260811012100-7ebd0ab8260f/go.mod h1:aTT2bB17VqAhdHHkScfDnMzJf8At3zYwGvTqntjiCwA=github.com/siyuan-note/encryption v0.0.0-20260715062728-9cb8e9548044 h1:b1/Q4DSREDvGh1/NbzR9873EKrjakdoUtsNlghWxUOI=github.com/siyuan-note/encryption v0.0.0-20260715062728-9cb8e9548044/go.mod h1:t6jXpJdrXzRsdQF+XGaw35f16JVZcDyIkk5/6//ywnY=github.com/siyuan-note/eventbus v0.0.0-20260530125927-d77c74260dce h1:356bfC3pucxXuYpZIwaQ3viVCbq5RbRuvBhb4xtoBR0=diff --git a/kernel/model/repository.go b/kernel/model/repository.goindex 6fa0c2d077..e271851d2e 100644--- a/kernel/model/repository.go+++ b/kernel/model/repository.go@@ -1925,24 +1925,15 @@ func bootSyncRepo() (err error) {}isBootSyncing.Store(true)- bootStart := time.Now()waitGroup := sync.WaitGroup{}- var beforeIndex, afterIndex *entity.Index- var indexElapsed time.Duration- var indexChangeGen uint64- var indexStable boolvar indexErr errorwaitGroup.Go(func() {defer logging.Recover()- indexStartChangeGen := syncDataChangeGen.Load()start := time.Now()- beforeIndex, afterIndex, indexErr = indexRepoBeforeCloudSync(repo)- indexElapsed = time.Since(start)- indexChangeGen = syncDataChangeGen.Load()- indexStable = indexStartChangeGen == indexChangeGen- logging.LogInfof("boot index repo elapsed [%.2fs]", indexElapsed.Seconds())+ _, _, indexErr = indexRepoBeforeCloudSync(repo)+ logging.LogInfof("boot index repo elapsed [%.2fs]", time.Since(start).Seconds())})var cloudLatest *entity.Indexvar cloudLatestErr error@@ -2019,11 +2010,12 @@ func bootSyncRepo() (err error) {defer unlockSync()logging.LogInfof("syncing prepared boot data repo [device=%s, kernel=%s, provider=%d]", Conf.System.ID, KernelID, Conf.Sync.Provider)- var syncErr error- if indexStable && indexChangeGen == syncDataChangeGen.Load() {- syncErr = syncIndexedRepoAfterBootWithDNSRetry(repo, beforeIndex, afterIndex, bootStart, indexElapsed, prefetchTraffic)- } else {- _, syncErr = syncRepoWithDNSRetry(false, false)+ syncStart := time.Now()+ indexStart := time.Now()+ beforeIndex, afterIndex, syncErr := indexRepoBeforeCloudSync(repo)+ indexElapsed := time.Since(indexStart)+ if nil == syncErr {+ syncErr = syncIndexedRepoAfterBootWithDNSRetry(repo, beforeIndex, afterIndex, syncStart, indexElapsed, prefetchTraffic)}if syncErr != nil {logging.LogErrorf("boot background sync repo failed: %s", syncErr)diff --git a/kernel/model/sync.go b/kernel/model/sync.goindex c04a19e613..d718c05583 100644--- a/kernel/model/sync.go+++ b/kernel/model/sync.go@@ -156,10 +156,9 @@ func SyncDataUpload() {}var (- syncSameCount = atomic.Int32{}- syncDataChangeGen = atomic.Uint64{}- autoSyncErrCount = 0- fixSyncInterval = 5 * time.Minute+ syncSameCount = atomic.Int32{}+ autoSyncErrCount = 0+ fixSyncInterval = 5 * time.MinutesyncPlanTimeLock = sync.Mutex{}syncPlanTime = time.Now().Add(fixSyncInterval)@@ -914,7 +913,6 @@ func getSyncIgnoreLines() (ret []string) {}func IncSync() {- syncDataChangeGen.Add(1)syncSameCount.Store(0)planSyncAfter(time.Duration(Conf.Sync.Interval) * time.Second)}