Skip to content

Commit

Permalink
Fix broken page when file is missing (#160)
Browse files Browse the repository at this point in the history
With the localfs backend, it's possible for a file to be removed but its
metadata file to remain intact. In this case, viewing the selif URL for
that file would return a broken page with two error pages stacked on top
of each other. This changes fixes that by replacing the output in that
case with a single "Unable to open file." error message.
  • Loading branch information
mutantmonkey authored and andreimarcu committed Jan 27, 2019
1 parent cde964f commit f46b613
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions fileserve.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,12 @@ func fileServeHandler(c web.C, w http.ResponseWriter, r *http.Request) {
w.Header().Set("Referrer-Policy", Config.fileReferrerPolicy)

_, reader, err := storageBackend.Get(fileName)
if err != nil {
oopsHandler(c, w, r, RespAUTO, err.Error())
if err == backends.NotFoundErr {
notFoundHandler(c, w, r)
return
} else if err != nil {
oopsHandler(c, w, r, RespAUTO, "Unable to open file.")
return
}

w.Header().Set("Content-Type", metadata.Mimetype)
Expand Down

0 comments on commit f46b613

Please sign in to comment.