Skip to content

Commit

Permalink
🎨 Kernel API /api/file/* no longer use HTTP status code #8329
Browse files Browse the repository at this point in the history
  • Loading branch information
88250 committed May 23, 2023
1 parent 5245de1 commit 7b0cfbe
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions kernel/api/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

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

Expand Down

0 comments on commit 7b0cfbe

Please sign in to comment.