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:
authorJaime Martinez <jmartinez@gitlab.com>2022-07-12 07:39:53 +0300
committerJaime Martinez <jmartinez@gitlab.com>2022-07-12 07:39:53 +0300
commit8dd16c9c043d08617a1d01d46880d7506a299ba2 (patch)
tree65537d02c52e4be9518e4ca6ebf87001ec94b076 /internal/vfs/zip/archive.go
parent1f9cc507928429fc0a85eaa504bfca692c56ff2a (diff)
parent57195a5ae472878c19dae4b6a65bc37a76e992e4 (diff)
Merge branch 'perf/lazy-open-serve' into 'master'revert-perf-lazy-open-master
perf: open files lazily when serving content See merge request gitlab-org/gitlab-pages!803
Diffstat (limited to 'internal/vfs/zip/archive.go')
-rw-r--r--internal/vfs/zip/archive.go19
1 files changed, 19 insertions, 0 deletions
diff --git a/internal/vfs/zip/archive.go b/internal/vfs/zip/archive.go
index 2b04310d..23ad7b2e 100644
--- a/internal/vfs/zip/archive.go
+++ b/internal/vfs/zip/archive.go
@@ -239,6 +239,25 @@ func (a *zipArchive) Open(ctx context.Context, name string) (vfs.File, error) {
}
}
+// IsCompressed finds the file by name and checks its compression method. If the method is
+// zip.Store it means it's not compressed.
+// Returns errNotFile for directories or non-regular files.
+func (a *zipArchive) IsCompressed(name string) (bool, error) {
+ file := a.findFile(name)
+ if file == nil {
+ if a.findDirectory(name) != nil {
+ return false, errNotFile
+ }
+ return false, os.ErrNotExist
+ }
+
+ if !file.Mode().IsRegular() {
+ return false, errNotFile
+ }
+
+ return file.Method != zip.Store, nil
+}
+
// Lstat finds the file by name inside the zipArchive and returns its FileInfo
func (a *zipArchive) Lstat(ctx context.Context, name string) (os.FileInfo, error) {
file := a.findFile(name)