소스 검색

:art: Improve kernel stability https://github.com/siyuan-note/siyuan/issues/9912

Daniel 1 년 전
부모
커밋
d8fb5f896e
2개의 변경된 파일11개의 추가작업 그리고 3개의 파일을 삭제
  1. 10 2
      kernel/model/mount.go
  2. 1 1
      kernel/model/transaction.go

+ 10 - 2
kernel/model/mount.go

@@ -41,6 +41,11 @@ func CreateBox(name string) (id string, err error) {
 		return
 	}
 
+	WaitForWritingFiles()
+
+	createDocLock.Lock()
+	defer createDocLock.Unlock()
+
 	id = ast.NewNodeID()
 	boxLocalPath := filepath.Join(util.DataDir, id)
 	err = os.MkdirAll(boxLocalPath, 0755)
@@ -71,12 +76,15 @@ func RenameBox(boxID, name string) (err error) {
 }
 
 func RemoveBox(boxID string) (err error) {
-	WaitForWritingFiles()
-
 	if util.IsReservedFilename(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)
 	if !filelock.IsExist(localPath) {
 		return

+ 1 - 1
kernel/model/transaction.go

@@ -87,7 +87,7 @@ var (
 )
 
 func isWritingFiles() bool {
-	time.Sleep(time.Duration(20) * time.Millisecond)
+	time.Sleep(time.Duration(50) * time.Millisecond)
 	return 0 < len(txQueue)
 }