mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-22 09:30:14 +01:00
🎨 Kernel API /api/file/* no longer use HTTP status code https://github.com/siyuan-note/siyuan/issues/8329
This commit is contained in:
parent
5245de1e15
commit
7b0cfbe0b4
1 changed files with 4 additions and 0 deletions
|
|
@ -93,18 +93,21 @@ func getFile(c *gin.Context) {
|
||||||
info, err := os.Stat(filePath)
|
info, err := os.Stat(filePath)
|
||||||
if os.IsNotExist(err) {
|
if os.IsNotExist(err) {
|
||||||
ret.Code = 404
|
ret.Code = 404
|
||||||
|
c.JSON(http.StatusOK, ret)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if nil != err {
|
if nil != err {
|
||||||
logging.LogErrorf("stat [%s] failed: %s", filePath, err)
|
logging.LogErrorf("stat [%s] failed: %s", filePath, err)
|
||||||
ret.Code = 500
|
ret.Code = 500
|
||||||
ret.Msg = err.Error()
|
ret.Msg = err.Error()
|
||||||
|
c.JSON(http.StatusOK, ret)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if info.IsDir() {
|
if info.IsDir() {
|
||||||
logging.LogErrorf("file [%s] is a directory", filePath)
|
logging.LogErrorf("file [%s] is a directory", filePath)
|
||||||
ret.Code = 405
|
ret.Code = 405
|
||||||
ret.Msg = "file is a directory"
|
ret.Msg = "file is a directory"
|
||||||
|
c.JSON(http.StatusOK, ret)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -113,6 +116,7 @@ func getFile(c *gin.Context) {
|
||||||
logging.LogErrorf("read file [%s] failed: %s", filePath, err)
|
logging.LogErrorf("read file [%s] failed: %s", filePath, err)
|
||||||
ret.Code = 500
|
ret.Code = 500
|
||||||
ret.Msg = err.Error()
|
ret.Msg = err.Error()
|
||||||
|
c.JSON(http.StatusOK, ret)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue