mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-02-14 11:14:21 +01:00
🎨 Data sync supports the multi-kernel online perception https://github.com/siyuan-note/siyuan/issues/8518
This commit is contained in:
parent
5e041d9017
commit
eaf29d918a
2 changed files with 7 additions and 3 deletions
|
|
@ -1102,7 +1102,7 @@ func bootSyncRepo() (err error) {
|
|||
return
|
||||
}
|
||||
|
||||
func syncRepo(exit, byHand bool) (mergeResult *dejavu.MergeResult, err error) {
|
||||
func syncRepo(exit, byHand bool) (dataChanged bool, err error) {
|
||||
if 1 > len(Conf.Repo.Key) {
|
||||
autoSyncErrCount++
|
||||
planSyncAfter(fixSyncInterval)
|
||||
|
|
@ -1126,6 +1126,7 @@ func syncRepo(exit, byHand bool) (mergeResult *dejavu.MergeResult, err error) {
|
|||
return
|
||||
}
|
||||
|
||||
latest, _ := repo.Latest()
|
||||
start := time.Now()
|
||||
err = indexRepoBeforeCloudSync(repo)
|
||||
if nil != err {
|
||||
|
|
@ -1167,6 +1168,9 @@ func syncRepo(exit, byHand bool) (mergeResult *dejavu.MergeResult, err error) {
|
|||
return
|
||||
}
|
||||
|
||||
syncedLatest, _ := repo.Latest()
|
||||
dataChanged = nil == latest || latest.ID != syncedLatest.ID
|
||||
|
||||
util.PushStatusBar(fmt.Sprintf(Conf.Language(149), elapsed.Seconds()))
|
||||
Conf.Sync.Synced = util.CurrentTimeMillis()
|
||||
msg := fmt.Sprintf(Conf.Language(150), trafficStat.UploadFileCount, trafficStat.DownloadFileCount, trafficStat.UploadChunkCount, trafficStat.DownloadChunkCount, humanize.Bytes(uint64(trafficStat.UploadBytes)), humanize.Bytes(uint64(trafficStat.DownloadBytes)))
|
||||
|
|
|
|||
|
|
@ -180,7 +180,7 @@ func syncData(exit, byHand, byWebSocket bool) {
|
|||
now := util.CurrentTimeMillis()
|
||||
Conf.Sync.Synced = now
|
||||
|
||||
mergeResult, err := syncRepo(exit, byHand)
|
||||
dataChanged, 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 && mergeResult.DataChanged() {
|
||||
if 1 == Conf.Sync.Mode && !byWebSocket && nil != webSocketConn && Conf.Sync.Perception && dataChanged {
|
||||
// 如果处于自动同步模式且不是又 WS 触发的同步,则通知其他设备上的内核进行同步
|
||||
request := map[string]interface{}{
|
||||
"cmd": "synced",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue