update go-store to latest

This commit is contained in:
tsmethurst 2022-01-29 12:15:51 +01:00
commit 4e74c84148
8 changed files with 70 additions and 52 deletions

View file

@ -3,30 +3,10 @@ package util
import (
"io/fs"
"os"
"strings"
"syscall"
"codeberg.org/gruf/go-fastpath"
)
// IsDirTraversal will check if rootPlusPath is a dir traversal outside of root,
// assuming that both are cleaned and that rootPlusPath is path.Join(root, somePath)
func IsDirTraversal(root string, rootPlusPath string) bool {
switch {
// Root is $PWD, check for traversal out of
case root == ".":
return strings.HasPrefix(rootPlusPath, "../")
// The path MUST be prefixed by root
case !strings.HasPrefix(rootPlusPath, root):
return true
// In all other cases, check not equal
default:
return len(root) == len(rootPlusPath)
}
}
// WalkDir traverses the dir tree of the supplied path, performing the supplied walkFn on each entry
func WalkDir(pb *fastpath.Builder, path string, walkFn func(string, fs.DirEntry)) error {
// Read supplied dir path
@ -100,14 +80,3 @@ func cleanDirs(pb *fastpath.Builder, path string) error {
}
return nil
}
// RetryOnEINTR is a low-level filesystem function for retrying syscalls on O_EINTR received
func RetryOnEINTR(do func() error) error {
for {
err := do()
if err == syscall.EINTR {
continue
}
return err
}
}

14
vendor/codeberg.org/gruf/go-store/util/sys.go generated vendored Normal file
View file

@ -0,0 +1,14 @@
package util
import "syscall"
// RetryOnEINTR is a low-level filesystem function for retrying syscalls on O_EINTR received
func RetryOnEINTR(do func() error) error {
for {
err := do()
if err == syscall.EINTR {
continue
}
return err
}
}