Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: Improve data synchronization to reduce the probability of conflicts https://github.com/siyuan-note/siyuan/issues/13065

Daniel2da780a04e34
diff --git a/kernel/model/repository.go b/kernel/model/repository.go
index d5cc82a607..e85af55974 100644
--- a/kernel/model/repository.go
+++ b/kernel/model/repository.go
@@ -645,6 +645,7 @@ func checkoutRepo(id string) {
// 回滚快照时默认为当前数据创建一个快照
// When rolling back a snapshot, a snapshot is created for the current data by default https://github.com/siyuan-note/siyuan/issues/12470
+ FlushTxQueue()
_, err = repo.Index("Backup before checkout", map[string]interface{}{eventbus.CtxPushMsg: eventbus.CtxPushMsgToStatusBarAndProgress})
if err != nil {
logging.LogErrorf("index repository failed: %s", err)
@@ -1627,7 +1628,9 @@ var promotedPurgeDataRepo bool
func indexRepoBeforeCloudSync(repo *dejavu.Repo) (beforeIndex, afterIndex *entity.Index, err error) {
start := time.Now()
+
beforeIndex, _ = repo.Latest()
+ FlushTxQueue()
afterIndex, err = repo.Index("[Sync] Cloud sync", map[string]interface{}{
eventbus.CtxPushMsg: eventbus.CtxPushMsgToStatusBar,
})