diff options
author | Unknwon <u@gogs.io> | 2017-03-13 05:26:17 -0400 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2017-03-13 05:26:17 -0400 |
commit | 24734a33e72dbdc1da4f7341cb2cf62521ce53f8 (patch) | |
tree | 08bf90a3a5a3273336d633db33c39c9a56a3fcf2 /cmd | |
parent | 1df54ea0cde038e2057d083078f952c072d0dc67 (diff) |
release: improve attachment handle
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/web.go | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -15,6 +15,7 @@ import ( "path" "strings" + "github.com/Unknwon/com" "github.com/go-macaron/binding" "github.com/go-macaron/cache" "github.com/go-macaron/captcha" @@ -323,11 +324,10 @@ func runWeb(ctx *cli.Context) error { m.Get("/attachments/:uuid", func(ctx *context.Context) { attach, err := models.GetAttachmentByUUID(ctx.Params(":uuid")) if err != nil { - if models.IsErrAttachmentNotExist(err) { - ctx.Error(404) - } else { - ctx.Handle(500, "GetAttachmentByUUID", err) - } + ctx.NotFoundOrServerError("GetAttachmentByUUID", models.IsErrAttachmentNotExist, err) + return + } else if !com.IsFile(attach.LocalPath()) { + ctx.NotFound() return } |