docker deploy
This commit is contained in:
parent
d30ef6cc9c
commit
ec83e3b08b
16 changed files with 236 additions and 335 deletions
src/host/vfs
|
@ -2,6 +2,7 @@ package vfs
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"io/fs"
|
||||
"strings"
|
||||
"sync"
|
||||
)
|
||||
|
@ -88,11 +89,11 @@ PARTS_LOOP:
|
|||
}
|
||||
|
||||
if nestOn == -1 {
|
||||
return name, nil, "", nil
|
||||
return clean(name), nil, "", nil
|
||||
}
|
||||
|
||||
fsPath = Clean(strings.Join(parts[:nestOn], Separator))
|
||||
nestedFsPath = Clean(strings.Join(parts[nestOn:], Separator))
|
||||
fsPath = clean(strings.Join(parts[:nestOn], Separator))
|
||||
nestedFsPath = clean(strings.Join(parts[nestOn:], Separator))
|
||||
|
||||
// we dont need lock until now
|
||||
// it must be before fsmap read to exclude race condition:
|
||||
|
@ -119,28 +120,42 @@ PARTS_LOOP:
|
|||
|
||||
}
|
||||
|
||||
// func (r *resolver) resolveFile(name string, fs Filesystem) (File, error) {
|
||||
// fsPath, nestedFs, nestedFsPath, err := r.resolvePath(name, fs)
|
||||
// if err != nil {
|
||||
// return nil, err
|
||||
// }
|
||||
var ErrNotExist = fs.ErrNotExist
|
||||
|
||||
// if nestedFs == nil {
|
||||
// return fs.Open(fsPath)
|
||||
// }
|
||||
func getFile[F File](m map[string]F, name string) (File, error) {
|
||||
name = clean(name)
|
||||
if name == Separator {
|
||||
return &Dir{}, nil
|
||||
}
|
||||
|
||||
// return nestedFs.Open(nestedFsPath)
|
||||
// }
|
||||
f, ok := m[name]
|
||||
if ok {
|
||||
return f, nil
|
||||
}
|
||||
|
||||
// func (r *resolver) resolveDir(name string, fs Filesystem) (map[string]File, error) {
|
||||
// fsPath, nestedFs, nestedFsPath, err := r.resolvePath(name, fs)
|
||||
// if err != nil {
|
||||
// return nil, err
|
||||
// }
|
||||
for p := range m {
|
||||
if strings.HasPrefix(p, name) {
|
||||
return &Dir{}, nil
|
||||
}
|
||||
}
|
||||
|
||||
// if nestedFs == nil {
|
||||
// return fs.ReadDir(fsPath)
|
||||
// }
|
||||
return nil, ErrNotExist
|
||||
}
|
||||
|
||||
// return nestedFs.ReadDir(nestedFsPath)
|
||||
// }
|
||||
func listFilesInDir[F File](m map[string]F, name string) (map[string]File, error) {
|
||||
name = clean(name)
|
||||
|
||||
out := map[string]File{}
|
||||
for p, f := range m {
|
||||
if strings.HasPrefix(p, name) {
|
||||
parts := strings.Split(trimRelPath(p, name), Separator)
|
||||
if len(parts) == 1 {
|
||||
out[parts[0]] = f
|
||||
} else {
|
||||
out[parts[0]] = &Dir{}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return out, nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue