🎨 细化云端同步锁提升稳定性 https://github.com/siyuan-note/siyuan/issues/5887

This commit is contained in:
Liang Ding 2022-09-17 21:35:42 +08:00
parent cd3da736db
commit e295c354d1
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
3 changed files with 7 additions and 4 deletions

View file

@ -141,6 +141,8 @@ func NetImg2LocalAssets(rootID string) (err error) {
name = util.FilterFileName(name)
name = "net-img-" + name + "-" + ast.NewNodeID() + ext
writePath := filepath.Join(util.DataDir, "assets", name)
writingDataLock.Lock()
defer writingDataLock.Unlock()
if err = gulu.File.WriteFileSafer(writePath, data, 0644); nil != err {
logging.LogErrorf("write downloaded net img [%s] to local assets [%s] failed: %s", u, writePath, err)
return ast.WalkSkipChildren

View file

@ -26,7 +26,6 @@ import (
"github.com/88250/lute/render"
"github.com/siyuan-note/filelock"
"github.com/siyuan-note/logging"
"github.com/siyuan-note/siyuan/kernel/sql"
"github.com/siyuan-note/siyuan/kernel/util"
)
@ -39,6 +38,8 @@ func AutoSpace(rootID string) (err error) {
util.PushEndlessProgress(Conf.Language(116))
defer util.ClearPushProgress(100)
WaitForWritingFiles()
generateFormatHistory(tree)
luteEngine := NewLute()
// 合并相邻的同类行级节点
@ -76,7 +77,7 @@ func AutoSpace(rootID string) (err error) {
if nil != err {
return
}
sql.WaitForWritingDatabase()
util.RandomSleep(500, 700)
return
}

View file

@ -351,8 +351,6 @@ func ImportFromLocalPath(boxID, localPath string, toPath string) (err error) {
util.PushEndlessProgress(Conf.Language(73))
WaitForWritingFiles()
writingDataLock.Lock()
defer writingDataLock.Unlock()
var baseHPath, baseTargetPath, boxLocalPath string
if "/" == toPath {
@ -503,6 +501,8 @@ func ImportFromLocalPath(boxID, localPath string, toPath string) (err error) {
})
reassignIDUpdated(tree)
writingDataLock.Lock()
defer writingDataLock.Unlock()
if err = filesys.WriteTree(tree); nil != err {
return io.EOF
}