mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-31 00:08:43 -06:00
🎨 Kernel API /api/file/* no longer use HTTP status code https://github.com/siyuan-note/siyuan/issues/8329
This commit is contained in:
@@ -93,18 +93,21 @@ func getFile(c *gin.Context) {
|
||||
info, err := os.Stat(filePath)
|
||||
if os.IsNotExist(err) {
|
||||
ret.Code = 404
|
||||
c.JSON(http.StatusOK, ret)
|
||||
return
|
||||
}
|
||||
if nil != err {
|
||||
logging.LogErrorf("stat [%s] failed: %s", filePath, err)
|
||||
ret.Code = 500
|
||||
ret.Msg = err.Error()
|
||||
c.JSON(http.StatusOK, ret)
|
||||
return
|
||||
}
|
||||
if info.IsDir() {
|
||||
logging.LogErrorf("file [%s] is a directory", filePath)
|
||||
ret.Code = 405
|
||||
ret.Msg = "file is a directory"
|
||||
c.JSON(http.StatusOK, ret)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -113,6 +116,7 @@ func getFile(c *gin.Context) {
|
||||
logging.LogErrorf("read file [%s] failed: %s", filePath, err)
|
||||
ret.Code = 500
|
||||
ret.Msg = err.Error()
|
||||
c.JSON(http.StatusOK, ret)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user