mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-11-02 11:22:26 -06:00
update go-store to latest
This commit is contained in:
parent
9aa364f1eb
commit
4e74c84148
8 changed files with 70 additions and 52 deletions
31
vendor/codeberg.org/gruf/go-store/util/fs.go
generated
vendored
31
vendor/codeberg.org/gruf/go-store/util/fs.go
generated
vendored
|
|
@ -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
14
vendor/codeberg.org/gruf/go-store/util/sys.go
generated
vendored
Normal 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
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue