mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-02-04 06:31:47 +01:00
🎨 文件系统读取或写入失败时退出内核 https://github.com/siyuan-note/siyuan/issues/7707
This commit is contained in:
parent
60f390d9e0
commit
7a078d3689
18 changed files with 3 additions and 162 deletions
|
|
@ -194,12 +194,6 @@ func checkBlockExist(c *gin.Context) {
|
|||
|
||||
id := arg["id"].(string)
|
||||
b, err := model.GetBlock(id, nil)
|
||||
// TODO 文件被锁的情况已经在 filelock 中做了退出进程处理,不会走到应用层,所以 code 为 2 的情况应该移除
|
||||
//if errors.Is(err, filelock.ErrUnableAccessFile) {
|
||||
// ret.Code = 2
|
||||
// ret.Data = id
|
||||
// return
|
||||
//}
|
||||
if errors.Is(err, model.ErrIndexing) {
|
||||
ret.Code = 0
|
||||
ret.Data = false
|
||||
|
|
@ -405,11 +399,6 @@ func getBlockInfo(c *gin.Context) {
|
|||
id := arg["id"].(string)
|
||||
|
||||
tree, err := model.LoadTreeByID(id)
|
||||
//if errors.Is(err, filelock.ErrUnableAccessFile) {
|
||||
// ret.Code = 2
|
||||
// ret.Data = id
|
||||
// return
|
||||
//}
|
||||
if errors.Is(err, model.ErrIndexing) {
|
||||
ret.Code = 3
|
||||
ret.Msg = model.Conf.Language(56)
|
||||
|
|
@ -438,11 +427,6 @@ func getBlockInfo(c *gin.Context) {
|
|||
}
|
||||
|
||||
root, err := model.GetBlock(block.RootID, tree)
|
||||
//if errors.Is(err, filelock.ErrUnableAccessFile) {
|
||||
// ret.Code = 2
|
||||
// ret.Data = id
|
||||
// return
|
||||
//}
|
||||
if errors.Is(err, model.ErrIndexing) {
|
||||
ret.Code = 3
|
||||
ret.Data = model.Conf.Language(56)
|
||||
|
|
|
|||
|
|
@ -501,24 +501,6 @@ func createDocWithMd(c *gin.Context) {
|
|||
pushCreate(box, p, id, arg)
|
||||
}
|
||||
|
||||
func lockFile(c *gin.Context) {
|
||||
ret := gulu.Ret.NewResult()
|
||||
defer c.JSON(http.StatusOK, ret)
|
||||
|
||||
arg, ok := util.JsonArg(c, ret)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
|
||||
id := arg["id"].(string)
|
||||
locked := model.TryAccessFileByBlockID(id)
|
||||
if !locked {
|
||||
ret.Code = -1
|
||||
ret.Msg = fmt.Sprintf(model.Conf.Language(75))
|
||||
ret.Data = map[string]interface{}{"closeTimeout": 5000}
|
||||
}
|
||||
}
|
||||
|
||||
func getDocCreateSavePath(c *gin.Context) {
|
||||
ret := gulu.Ret.NewResult()
|
||||
defer c.JSON(http.StatusOK, ret)
|
||||
|
|
@ -689,11 +671,6 @@ func getDoc(c *gin.Context) {
|
|||
}
|
||||
|
||||
blockCount, content, parentID, parent2ID, rootID, typ, eof, scroll, boxID, docPath, isBacklinkExpand, err := model.GetDoc(startID, endID, id, index, keyword, mode, size, isBacklink)
|
||||
//if errors.Is(err, filelock.ErrUnableAccessFile) {
|
||||
// ret.Code = 2
|
||||
// ret.Data = id
|
||||
// return
|
||||
//}
|
||||
if model.ErrBlockNotFound == err {
|
||||
ret.Code = 3
|
||||
return
|
||||
|
|
|
|||
|
|
@ -89,7 +89,6 @@ func ServeAPI(ginServer *gin.Engine) {
|
|||
ginServer.Handle("POST", "/api/filetree/getDocCreateSavePath", model.CheckAuth, getDocCreateSavePath)
|
||||
ginServer.Handle("POST", "/api/filetree/getRefCreateSavePath", model.CheckAuth, getRefCreateSavePath)
|
||||
ginServer.Handle("POST", "/api/filetree/changeSort", model.CheckAuth, model.CheckReadonly, changeSort)
|
||||
ginServer.Handle("POST", "/api/filetree/lockFile", model.CheckAuth, lockFile)
|
||||
ginServer.Handle("POST", "/api/filetree/createDocWithMd", model.CheckAuth, model.CheckReadonly, createDocWithMd)
|
||||
ginServer.Handle("POST", "/api/filetree/createDailyNote", model.CheckAuth, model.CheckReadonly, createDailyNote)
|
||||
ginServer.Handle("POST", "/api/filetree/createDoc", model.CheckAuth, model.CheckReadonly, createDoc)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue