🎨 Kernel API /api/file/* no longer use HTTP status code https://github.com/siyuan-note/siyuan/issues/8329

This commit is contained in:
Daniel 2023-05-23 09:53:05 +08:00
parent 5245de1e15
commit 7b0cfbe0b4
No known key found for this signature in database
GPG key ID: 86211BA83DF03017

View file

@ -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
}