Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-pages.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--internal/serving/disk/reader.go5
-rw-r--r--internal/vfs/zip/vfs.go15
2 files changed, 14 insertions, 6 deletions
diff --git a/internal/serving/disk/reader.go b/internal/serving/disk/reader.go
index 61316509..258df3bc 100644
--- a/internal/serving/disk/reader.go
+++ b/internal/serving/disk/reader.go
@@ -251,6 +251,11 @@ func (reader *Reader) serveCustomFile(ctx context.Context, w http.ResponseWriter
// Open and serve content of file
file, err := root.Open(ctx, fullPath)
if err != nil {
+ // Handle context.Canceled error as not exist https://gitlab.com/gitlab-org/gitlab-pages/-/issues/669
+ if errors.Is(err, context.Canceled) {
+ return fs.ErrNotExist
+ }
+
return err
}
defer file.Close()
diff --git a/internal/vfs/zip/vfs.go b/internal/vfs/zip/vfs.go
index c28ec017..cc0ff290 100644
--- a/internal/vfs/zip/vfs.go
+++ b/internal/vfs/zip/vfs.go
@@ -179,13 +179,16 @@ func (zfs *zipVFS) Root(ctx context.Context, path string, cacheKey string) (vfs.
// we do it in loop to not use any additional locks
for {
root, err := zfs.findOrOpenArchive(ctx, cacheKey, path)
- if errors.Is(err, errAlreadyCached) {
- continue
- }
-
- // If archive is not found, return a known `vfs` error
- if errors.Is(err, httprange.ErrNotFound) {
+ switch err {
+ case context.Canceled:
+ // treat user-initiated cancellations as not found and
+ // do not report a 500 https://gitlab.com/gitlab-org/gitlab-pages/-/issues/669
+ fallthrough
+ case httprange.ErrNotFound:
+ // If archive is not found, return a known `vfs` error
return nil, fs.ErrNotExist
+ case errAlreadyCached:
+ continue
}
return root, err