mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-18 23:50:13 +01:00
🎨 Improve kernel stability https://github.com/siyuan-note/siyuan/issues/9912
This commit is contained in:
parent
3907165090
commit
d8fb5f896e
2 changed files with 11 additions and 3 deletions
|
|
@ -41,6 +41,11 @@ func CreateBox(name string) (id string, err error) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WaitForWritingFiles()
|
||||||
|
|
||||||
|
createDocLock.Lock()
|
||||||
|
defer createDocLock.Unlock()
|
||||||
|
|
||||||
id = ast.NewNodeID()
|
id = ast.NewNodeID()
|
||||||
boxLocalPath := filepath.Join(util.DataDir, id)
|
boxLocalPath := filepath.Join(util.DataDir, id)
|
||||||
err = os.MkdirAll(boxLocalPath, 0755)
|
err = os.MkdirAll(boxLocalPath, 0755)
|
||||||
|
|
@ -71,12 +76,15 @@ func RenameBox(boxID, name string) (err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func RemoveBox(boxID string) (err error) {
|
func RemoveBox(boxID string) (err error) {
|
||||||
WaitForWritingFiles()
|
|
||||||
|
|
||||||
if util.IsReservedFilename(boxID) {
|
if util.IsReservedFilename(boxID) {
|
||||||
return errors.New(fmt.Sprintf("can not remove [%s] caused by it is a reserved file", boxID))
|
return errors.New(fmt.Sprintf("can not remove [%s] caused by it is a reserved file", boxID))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WaitForWritingFiles()
|
||||||
|
|
||||||
|
createDocLock.Lock()
|
||||||
|
defer createDocLock.Unlock()
|
||||||
|
|
||||||
localPath := filepath.Join(util.DataDir, boxID)
|
localPath := filepath.Join(util.DataDir, boxID)
|
||||||
if !filelock.IsExist(localPath) {
|
if !filelock.IsExist(localPath) {
|
||||||
return
|
return
|
||||||
|
|
|
||||||
|
|
@ -87,7 +87,7 @@ var (
|
||||||
)
|
)
|
||||||
|
|
||||||
func isWritingFiles() bool {
|
func isWritingFiles() bool {
|
||||||
time.Sleep(time.Duration(20) * time.Millisecond)
|
time.Sleep(time.Duration(50) * time.Millisecond)
|
||||||
return 0 < len(txQueue)
|
return 0 < len(txQueue)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue