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:
authorKamil Trzciński <ayufan@ayufan.eu>2019-03-01 13:26:24 +0300
committerKamil Trzciński <ayufan@ayufan.eu>2019-03-01 13:26:24 +0300
commit77a49c65a81a74a0ce78805900ee4fb6b3a17b34 (patch)
treee0fb70cdf1276f351707d784af1f48255163f9d2 /internal/storage
parent48c69b669c940f751ba92466018aed3354ef9bd0 (diff)
Add zip storage
Diffstat (limited to 'internal/storage')
-rw-r--r--internal/storage/file_system.go3
-rw-r--r--internal/storage/storage.go12
-rw-r--r--internal/storage/zip_storage.go31
3 files changed, 44 insertions, 2 deletions
diff --git a/internal/storage/file_system.go b/internal/storage/file_system.go
index 15cec77d..18a228a6 100644
--- a/internal/storage/file_system.go
+++ b/internal/storage/file_system.go
@@ -76,3 +76,6 @@ func (f *fileSystem) Open(path string) (File, os.FileInfo, error) {
return file, fileInfo, err
}
+
+func (f *fileSystem) Close() {
+}
diff --git a/internal/storage/storage.go b/internal/storage/storage.go
index 00eef899..58e1cd49 100644
--- a/internal/storage/storage.go
+++ b/internal/storage/storage.go
@@ -1,6 +1,7 @@
package storage
import (
+ "errors"
"io"
"os"
@@ -21,9 +22,16 @@ type S interface {
Resolve(path string) (string, error)
Stat(path string) (os.FileInfo, error)
Open(path string) (File, os.FileInfo, error)
+ Close()
}
// New provides a compatible storage with lookupPath
-func New(lookupPath *client.LookupPath) S {
- return &fileSystem{lookupPath}
+func New(lookupPath *client.LookupPath) (S, error) {
+ if lookupPath.DiskPath != "" {
+ return &fileSystem{lookupPath}, nil
+ } else if lookupPath.ArchivePath != "" {
+ return newZipStorage(lookupPath)
+ } else {
+ return nil, errors.New("storage not supported")
+ }
}
diff --git a/internal/storage/zip_storage.go b/internal/storage/zip_storage.go
new file mode 100644
index 00000000..75611f11
--- /dev/null
+++ b/internal/storage/zip_storage.go
@@ -0,0 +1,31 @@
+package storage
+
+import (
+ "archive/zip"
+ "errors"
+ "os"
+
+ "gitlab.com/gitlab-org/gitlab-pages/internal/client"
+)
+
+type zipStorage struct {
+ *client.LookupPath
+
+ zipArchive *zip.ReadCloser
+}
+
+func (z *zipStorage) Resolve(path string) (string, error) {
+ return "", errors.New("not supported")
+}
+
+func (z *zipStorage) Stat(path string) (os.FileInfo, error) {
+ return nil, errors.New("not supported")
+}
+
+func (z *zipStorage) Open(path string) (File, os.FileInfo, error) {
+ return nil, nil, errors.New("not supported")
+}
+
+func newZipStorage(lookupPath *client.LookupPath) (S, error) {
+ return nil, errors.New("not supported")
+}