diff options
author | zeripath <art27@cantab.net> | 2020-10-18 02:29:06 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-17 21:29:06 -0400 |
commit | 25b7766673867d2a9ac32fde6cb0d719f04b2953 (patch) | |
tree | 41e06110a3c25e213a648e830a7d22d2c1ea8f3b /routers/routes | |
parent | 4cc8697a652a60263149fb794c46df87d19eff74 (diff) | |
download | gitea-25b7766673867d2a9ac32fde6cb0d719f04b2953.tar.gz gitea-25b7766673867d2a9ac32fde6cb0d719f04b2953.zip |
When handling errors in storageHandler check underlying error (#13178)
Unfortunately there was a mistake in #13164 which fails to handle
os.PathError wrapping an os.ErrNotExist
Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Diffstat (limited to 'routers/routes')
-rw-r--r-- | routers/routes/routes.go | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/routers/routes/routes.go b/routers/routes/routes.go index adda919857..9f7ff277cf 100644 --- a/routers/routes/routes.go +++ b/routers/routes/routes.go @@ -7,6 +7,7 @@ package routes import ( "bytes" "encoding/gob" + "errors" "fmt" "io" "net/http" @@ -127,7 +128,7 @@ func storageHandler(storageSetting setting.Storage, prefix string, objStore stor rPath := strings.TrimPrefix(req.RequestURI, "/"+prefix) u, err := objStore.URL(rPath, path.Base(rPath)) if err != nil { - if err == os.ErrNotExist { + if os.IsNotExist(err) || errors.Is(err, os.ErrNotExist) { log.Warn("Unable to find %s %s", prefix, rPath) ctx.Error(404, "file not found") return @@ -160,7 +161,7 @@ func storageHandler(storageSetting setting.Storage, prefix string, objStore stor //If we have matched and access to release or issue fr, err := objStore.Open(rPath) if err != nil { - if err == os.ErrNotExist { + if os.IsNotExist(err) || errors.Is(err, os.ErrNotExist) { log.Warn("Unable to find %s %s", prefix, rPath) ctx.Error(404, "file not found") return |