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:
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)