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-02-28 20:53:43 +0300
committerKamil Trzciński <ayufan@ayufan.eu>2019-02-28 20:53:43 +0300
commit57f798df3d176f84a977c1bb9200817293441323 (patch)
tree9257873f07fd8fbc5d683c91612603d9fafbb550 /internal/client
parent3e4b32197248b105e86bf059a59ad7bab531cbd0 (diff)
Add storage interface
Diffstat (limited to 'internal/client')
-rw-r--r--internal/client/lookup_path.go65
1 files changed, 0 insertions, 65 deletions
diff --git a/internal/client/lookup_path.go b/internal/client/lookup_path.go
index d618a356..41d79063 100644
--- a/internal/client/lookup_path.go
+++ b/internal/client/lookup_path.go
@@ -1,17 +1,9 @@
package client
import (
- "fmt"
- "os"
- "path/filepath"
"strings"
-
- "golang.org/x/sys/unix"
)
-// TODO: This is hack to pass the location
-var RootPath string
-
type LookupPath struct {
Prefix string `json:"prefix"`
Path string `json:"path"`
@@ -29,60 +21,3 @@ func (lp *LookupPath) Tail(path string) string {
return ""
}
-
-func (lp *LookupPath) rootPath() string {
- fullPath, err := filepath.EvalSymlinks(filepath.Join(RootPath, lp.Path))
- if err != nil {
- return ""
- }
-
- return fullPath
-}
-
-func (lp *LookupPath) resolvePath(path string) (string, error) {
- fullPath := filepath.Join(lp.rootPath(), path)
- fullPath, err := filepath.EvalSymlinks(fullPath)
- if err != nil {
- return "", err
- }
-
- // The requested path resolved to somewhere outside of the public/ directory
- if !strings.HasPrefix(fullPath, lp.rootPath()) {
- return "", fmt.Errorf("%q should be in %q", fullPath, lp.rootPath())
- }
-
- return fullPath, nil
-}
-
-func (lp *LookupPath) Resolve(path string) (string, error) {
- fullPath, err := lp.resolvePath(path)
- if err != nil {
- println("LookupPath::Resolve", lp.rootPath(), "PATH=", path, "FULLPATH=", fullPath, "ERROR", err.Error())
- return "", err
- }
-
- println("LookupPath::Resolve", lp.rootPath(), "PATH=", path, "FULLPATH=", fullPath, err)
- return fullPath[len(lp.rootPath()):], nil
-}
-
-func (lp *LookupPath) Stat(path string) (os.FileInfo, error) {
- fullPath, err := lp.resolvePath(path)
- if err != nil {
- println("LookupPath::Stat", lp.rootPath(), "PATH=", path, "FULLPATH=", fullPath, "ERROR", err.Error())
- return nil, err
- }
-
- println("LookupPath::Stat", lp.rootPath(), "PATH=", path, "FULLPATH=", fullPath, err)
- return os.Lstat(fullPath)
-}
-
-func (lp *LookupPath) Open(path string) (*os.File, error) {
- fullPath, err := lp.resolvePath(path)
- if err != nil {
- println("LookupPath::Open", lp.rootPath(), "PATH=", path, "FULLPATH=", fullPath, "ERROR", err.Error())
- return nil, err
- }
-
- println("LookupPath::Open", lp.rootPath(), "PATH=", path, "FULLPATH=", fullPath, err)
- return os.OpenFile(fullPath, os.O_RDONLY|unix.O_NOFOLLOW, 0)
-}