diff options
Diffstat (limited to 'internal/serving/disk/reader.go')
-rw-r--r-- | internal/serving/disk/reader.go | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/internal/serving/disk/reader.go b/internal/serving/disk/reader.go index f250a0d6..7a1af61b 100644 --- a/internal/serving/disk/reader.go +++ b/internal/serving/disk/reader.go @@ -18,6 +18,7 @@ import ( "gitlab.com/gitlab-org/gitlab-pages/internal/logging" "gitlab.com/gitlab-org/gitlab-pages/internal/redirects" "gitlab.com/gitlab-org/gitlab-pages/internal/serving" + "gitlab.com/gitlab-org/gitlab-pages/internal/serving/disk/projectroot" "gitlab.com/gitlab-org/gitlab-pages/internal/serving/disk/symlink" "gitlab.com/gitlab-org/gitlab-pages/internal/vfs" vfsServing "gitlab.com/gitlab-org/gitlab-pages/internal/vfs/serving" @@ -284,11 +285,18 @@ func (reader *Reader) serveCustomFile(ctx context.Context, w http.ResponseWriter return nil } -// root tries to resolve the vfs.Root and handles errors for it. +// root tries to resolve the vfs.Root, wrap it in a projectroot.Root and handles +// errors for it. // It returns whether we served the response or not. func (reader *Reader) root(h serving.Handler) (vfs.Root, bool) { - root, err := reader.vfs.Root(h.Request.Context(), h.LookupPath.Path, h.LookupPath.SHA256) + vfsRoot, err := reader.vfs.Root(h.Request.Context(), h.LookupPath.Path, + h.LookupPath.SHA256) + if err == nil { + // The project root directory changes based on the response obtained + // from the API. It currently depends on feature.ConfigurableRoot + // being enabled. + root := projectroot.New(h.LookupPath.RootDirectory, vfsRoot) return root, false } |