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

This commit is contained in:
Liang Ding 2022-09-18 09:14:34 +08:00
parent 963b409e4e
commit 11e4c88f5a
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
15 changed files with 110 additions and 106 deletions

View file

@ -29,13 +29,12 @@ import (
"github.com/88250/lute/ast"
"github.com/siyuan-note/filelock"
"github.com/siyuan-note/logging"
"github.com/siyuan-note/siyuan/kernel/filesys"
"github.com/siyuan-note/siyuan/kernel/treenode"
"github.com/siyuan-note/siyuan/kernel/util"
)
func CreateBox(name string) (id string, err error) {
WaitForWritingFiles()
id = ast.NewNodeID()
boxLocalPath := filepath.Join(util.DataDir, id)
err = os.MkdirAll(boxLocalPath, 0755)
@ -52,10 +51,6 @@ func CreateBox(name string) (id string, err error) {
}
func RenameBox(boxID, name string) (err error) {
WaitForWritingFiles()
util.LockWriteFile()
defer util.UnlockWriteFile()
box := Conf.Box(boxID)
if nil == box {
return errors.New(Conf.Language(0))
@ -103,7 +98,7 @@ func RemoveBox(boxID string) (err error) {
}
unmount0(boxID)
if err = os.RemoveAll(localPath); nil != err {
if err = filesys.RemoveAll(localPath); nil != err {
return
}
IncSync()