云端数据同步时降低交互阻塞时间 Fix https://github.com/siyuan-note/siyuan/issues/4984

This commit is contained in:
Liang Ding 2022-05-30 10:50:12 +08:00
parent 1cdc80e1bd
commit c88bd514d3
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
10 changed files with 63 additions and 91 deletions

View file

@ -73,9 +73,6 @@ func SyncData(boot, exit, byHand bool) {
return
}
syncLock.Lock()
defer syncLock.Unlock()
if boot {
util.IncBootProgress(3, "Syncing data from the cloud...")
BootSyncSucc = 0
@ -127,8 +124,11 @@ func SyncData(boot, exit, byHand bool) {
util.BroadcastByType("main", "syncing", 1, msg, nil)
}()
syncLock.Lock()
defer syncLock.Unlock()
WaitForWritingFiles()
writingTreeLock.Lock()
writingDataLock.Lock()
var err error
// 将 data 变更同步到 sync
if err = workspaceData2SyncDir(); nil != err {
@ -141,7 +141,7 @@ func SyncData(boot, exit, byHand bool) {
if exit {
ExitSyncSucc = 1
}
writingTreeLock.Unlock()
writingDataLock.Unlock()
return
}
@ -156,10 +156,10 @@ func SyncData(boot, exit, byHand bool) {
if exit {
ExitSyncSucc = 1
}
writingTreeLock.Unlock()
writingDataLock.Unlock()
return
}
writingTreeLock.Unlock()
writingDataLock.Unlock()
cloudSyncVer, err := getCloudSyncVer(Conf.Sync.CloudName)
if nil != err {