🎨 Data sync supports the multi-kernel online perception https://github.com/siyuan-note/siyuan/issues/8518

This commit is contained in:
Daniel 2023-06-12 20:04:24 +08:00
parent 18985de1e5
commit 5e041d9017
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
4 changed files with 8 additions and 8 deletions

View file

@ -1092,7 +1092,7 @@ func bootSyncRepo() (err error) {
if 0 < len(fetchedFiles) {
go func() {
syncErr := syncRepo(false, false)
_, syncErr := syncRepo(false, false)
if nil != err {
logging.LogErrorf("boot background sync repo failed: %s", syncErr)
return
@ -1102,7 +1102,7 @@ func bootSyncRepo() (err error) {
return
}
func syncRepo(exit, byHand bool) (err error) {
func syncRepo(exit, byHand bool) (mergeResult *dejavu.MergeResult, err error) {
if 1 > len(Conf.Repo.Key) {
autoSyncErrCount++
planSyncAfter(fixSyncInterval)

View file

@ -180,7 +180,7 @@ func syncData(exit, byHand, byWebSocket bool) {
now := util.CurrentTimeMillis()
Conf.Sync.Synced = now
err := syncRepo(exit, byHand)
mergeResult, err := syncRepo(exit, byHand)
code := 1
if nil != err {
code = 2
@ -192,7 +192,7 @@ func syncData(exit, byHand, byWebSocket bool) {
connectSyncWebSocket()
}
if 1 == Conf.Sync.Mode && !byWebSocket && nil != webSocketConn && Conf.Sync.Perception {
if 1 == Conf.Sync.Mode && !byWebSocket && nil != webSocketConn && Conf.Sync.Perception && mergeResult.DataChanged() {
// 如果处于自动同步模式且不是又 WS 触发的同步,则通知其他设备上的内核进行同步
request := map[string]interface{}{
"cmd": "synced",