Return 404 always on error

This commit is contained in:
Wim 2022-11-01 21:21:46 +01:00
parent 4511c4c017
commit 9ed3fcd793
No known key found for this signature in database

View File

@ -1,9 +1,7 @@
package gitea package gitea
import ( import (
"errors"
"io" "io"
"io/fs"
"net/http" "net/http"
"strings" "strings"
@ -75,9 +73,7 @@ func (m Middleware) ServeHTTP(w http.ResponseWriter, r *http.Request, _ caddyhtt
f, err := m.Client.Open(fp, r.URL.Query().Get("ref")) f, err := m.Client.Open(fp, r.URL.Query().Get("ref"))
if err != nil { if err != nil {
if errors.Is(err, fs.ErrNotExist) { return caddyhttp.Error(http.StatusNotFound, err)
return caddyhttp.Error(http.StatusNotFound, err)
}
} }
_, err = io.Copy(w, f) _, err = io.Copy(w, f)