diff options
author | Jaime Martinez <jmartinez@gitlab.com> | 2020-09-21 06:48:54 +0300 |
---|---|---|
committer | Vladimir Shushlin <v.shushlin@gmail.com> | 2020-09-21 13:53:18 +0300 |
commit | e2998d393d7940153588266b2e8a8596f4def02c (patch) | |
tree | 00ea8221983547c56cdaaee63b13e4b3e4739a2e /internal/serving | |
parent | 2b9ccbc12eb270cab09811695c0c3721ba8e20b3 (diff) |
Apply suggestions from feedback
Diffstat (limited to 'internal/serving')
-rw-r--r-- | internal/serving/disk/reader.go | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/internal/serving/disk/reader.go b/internal/serving/disk/reader.go index a0c0ed0d..caaccdc3 100644 --- a/internal/serving/disk/reader.go +++ b/internal/serving/disk/reader.go @@ -11,6 +11,7 @@ import ( "time" "github.com/prometheus/client_golang/prometheus" + log "github.com/sirupsen/logrus" "gitlab.com/gitlab-org/gitlab-pages/internal/redirects" "gitlab.com/gitlab-org/gitlab-pages/internal/serving" @@ -198,10 +199,12 @@ func (reader *Reader) serveFile(ctx context.Context, w http.ResponseWriter, r *h reader.fileSizeMetric.Observe(float64(fi.Size())) - // Support SeekableFile if available + // This is just a failsafe as we need to assert that file is of type + // vfs.SeekableFile before passing onto http.ServeContent if rs, ok := file.(vfs.SeekableFile); ok { http.ServeContent(w, r, origPath, fi.ModTime(), rs) } else { + log.WithField("filename", fi.Name()).Traceln("file is not seekable") w.Header().Set("Content-Length", strconv.FormatInt(fi.Size(), 10)) io.Copy(w, file) } |