云端数据同步时降低交互阻塞时间 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

@ -841,9 +841,6 @@ func DuplicateDoc(rootID string) (err error) {
defer util.PushClearMsg()
WaitForWritingFiles()
syncLock.Lock()
defer syncLock.Unlock()
tree, err := loadTreeByBlockID(rootID)
if nil != err {
return
@ -890,8 +887,6 @@ func DuplicateDoc(rootID string) (err error) {
func CreateDocByMd(boxID, p, title, md string) (err error) {
WaitForWritingFiles()
syncLock.Lock()
defer syncLock.Unlock()
box := Conf.Box(boxID)
if nil == box {
@ -911,9 +906,6 @@ func CreateWithMarkdown(boxID, hPath, md string) (id string, err error) {
}
WaitForWritingFiles()
syncLock.Lock()
defer syncLock.Unlock()
luteEngine := NewLute()
dom := luteEngine.Md2BlockDOM(md)
id, err = createDocsByHPath(box.ID, hPath, dom)
@ -981,8 +973,8 @@ func MoveDoc(fromBoxID, fromPath, toBoxID, toPath string) (newPath string, err e
}
WaitForWritingFiles()
syncLock.Lock()
defer syncLock.Unlock()
writingDataLock.Lock()
defer writingDataLock.Unlock()
tree, err := LoadTree(fromBoxID, fromPath)
if nil != err {
@ -1109,8 +1101,8 @@ func RemoveDoc(boxID, p string) (err error) {
}
WaitForWritingFiles()
syncLock.Lock()
defer syncLock.Unlock()
writingDataLock.Lock()
defer writingDataLock.Unlock()
tree, err := LoadTree(boxID, p)
if nil != err {
@ -1241,8 +1233,6 @@ func CreateDailyNote(boxID string) (p string, err error) {
}
WaitForWritingFiles()
syncLock.Lock()
defer syncLock.Unlock()
existRoot := treenode.GetBlockTreeRootByHPath(box.ID, hPath)
if nil != existRoot {
@ -1453,8 +1443,8 @@ func rootChildIDs(rootID string) (ret []string) {
func ChangeFileTreeSort(boxID string, paths []string) {
WaitForWritingFiles()
syncLock.Lock()
defer syncLock.Unlock()
writingDataLock.Lock()
defer writingDataLock.Unlock()
box := Conf.Box(boxID)
sortIDs := map[string]int{}
@ -1609,8 +1599,6 @@ func (box *Box) removeSort(rootID, path string) {
func ServeFile(c *gin.Context, filePath string) (err error) {
WaitForWritingFiles()
syncLock.Lock()
defer syncLock.Unlock()
if filesys.IsLocked(filePath) {
if err = filesys.UnlockFile(filePath); nil == err {