commit fe39d50e09c1fcf5d13386e15951c5608e7df0e4
parent 0c1b1b01f89461ebf7da1e588de46edcd05f4d2d
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date: Mon, 28 Nov 2022 09:01:53 +0000
[chore]: Bump codeberg.org/gruf/go-store/v2 from 2.0.9 to 2.0.10 (#1160)
Bumps codeberg.org/gruf/go-store/v2 from 2.0.9 to 2.0.10.
---
updated-dependencies:
- dependency-name: codeberg.org/gruf/go-store/v2
dependency-type: direct:production
update-type: version-update:semver-patch
...
Signed-off-by: dependabot[bot] <support@github.com>
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Diffstat:
10 files changed, 363 insertions(+), 18 deletions(-)
diff --git a/go.mod b/go.mod
@@ -12,7 +12,7 @@ require (
codeberg.org/gruf/go-logger/v2 v2.2.1
codeberg.org/gruf/go-mutexes v1.1.4
codeberg.org/gruf/go-runners v1.3.1
- codeberg.org/gruf/go-store/v2 v2.0.9
+ codeberg.org/gruf/go-store/v2 v2.0.10
github.com/buckket/go-blurhash v1.1.0
github.com/coreos/go-oidc/v3 v3.4.0
github.com/cornelk/hashmap v1.0.8
@@ -65,6 +65,7 @@ require (
codeberg.org/gruf/go-bytes v1.0.2 // indirect
codeberg.org/gruf/go-fastcopy v1.1.1 // indirect
codeberg.org/gruf/go-fastpath v1.0.3 // indirect
+ codeberg.org/gruf/go-fastpath/v2 v2.0.0 // indirect
codeberg.org/gruf/go-hashenc v1.0.2 // indirect
codeberg.org/gruf/go-mangler v1.1.1 // indirect
codeberg.org/gruf/go-maps v1.0.3 // indirect
diff --git a/go.sum b/go.sum
@@ -81,6 +81,8 @@ codeberg.org/gruf/go-fastcopy v1.1.1/go.mod h1:GDDYR0Cnb3U/AIfGM3983V/L+GN+vuwVM
codeberg.org/gruf/go-fastpath v1.0.1/go.mod h1:edveE/Kp3Eqi0JJm0lXYdkVrB28cNUkcb/bRGFTPqeI=
codeberg.org/gruf/go-fastpath v1.0.3 h1:3Iftz9Z2suCEgTLkQMucew+2+4Oe46JPbAM2JEhnjTU=
codeberg.org/gruf/go-fastpath v1.0.3/go.mod h1:edveE/Kp3Eqi0JJm0lXYdkVrB28cNUkcb/bRGFTPqeI=
+codeberg.org/gruf/go-fastpath/v2 v2.0.0 h1:iAS9GZahFhyWEH0KLhFEJR+txx1ZhMXxYzu2q5Qo9c0=
+codeberg.org/gruf/go-fastpath/v2 v2.0.0/go.mod h1:3pPqu5nZjpbRrOqvLyAK7puS1OfEtQvjd6342Cwz56Q=
codeberg.org/gruf/go-hashenc v1.0.2 h1:U3jH6zMXZiL96czD/qaJd8OR2h7LlBzGv/2WxnMHI/g=
codeberg.org/gruf/go-hashenc v1.0.2/go.mod h1:eK+A8clLcEN/m1nftNsRId0kfYDQnETnuIfBGZ8Gvsg=
codeberg.org/gruf/go-kv v1.5.2 h1:B0RkAXLUXYn3Za1NzTXOcUvAc+JUC2ZadTMkCUDa0mc=
@@ -99,8 +101,8 @@ codeberg.org/gruf/go-runners v1.3.1 h1:d/OQMMMiA6yPaDSbSr0/Jc+lucWmm7AiAZjWffpNK
codeberg.org/gruf/go-runners v1.3.1/go.mod h1:rl0EdZNozkRMb21DAtOL5L4oTfmslYQdZgq2RMMc/H4=
codeberg.org/gruf/go-sched v1.1.1 h1:YtLSQhpypzuD3HTup5oF7LLWB79gTL4nqW06kH4Vwks=
codeberg.org/gruf/go-sched v1.1.1/go.mod h1:SRcdP/5qim+EBT3n3r4aUra1C30yPqV4OJOXuqvgdQM=
-codeberg.org/gruf/go-store/v2 v2.0.9 h1:nFurtZCBdZac79aXo3PFPVn2N744B06dHLygVrHf+SA=
-codeberg.org/gruf/go-store/v2 v2.0.9/go.mod h1:D4r5PV0BXDhxQyATw/03JkwvziZDkVMgzTpElZyWTXI=
+codeberg.org/gruf/go-store/v2 v2.0.10 h1:/2iZ4j29A//EhM3XziJP6SxtdIcaAyPmJEv31+6XD8g=
+codeberg.org/gruf/go-store/v2 v2.0.10/go.mod h1:KMRE173S6W2sGhuIa4jY/OPIO65F9++7rmWTfZ4xTeY=
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
diff --git a/vendor/codeberg.org/gruf/go-fastpath/v2/LICENSE b/vendor/codeberg.org/gruf/go-fastpath/v2/LICENSE
@@ -0,0 +1,9 @@
+MIT License
+
+Copyright (c) 2021 gruf
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/vendor/codeberg.org/gruf/go-fastpath/v2/README.md b/vendor/codeberg.org/gruf/go-fastpath/v2/README.md
@@ -0,0 +1 @@
+Alternative path library with a `strings.Builder` like path builder.
+\ No newline at end of file
diff --git a/vendor/codeberg.org/gruf/go-fastpath/v2/path.go b/vendor/codeberg.org/gruf/go-fastpath/v2/path.go
@@ -0,0 +1,326 @@
+package fastpath
+
+import (
+ "unsafe"
+)
+
+// Clean: see Builder.Clean(). Analogous to path.Clean().
+func Clean(path string) string {
+ return (&Builder{}).Clean(path)
+}
+
+// Join: see Builder.Join(). Analogous to path.Join().
+func Join(elems ...string) string {
+ return (&Builder{}).Join(elems...)
+}
+
+// Builder provides a means of cleaning and joining system paths,
+// while retaining a singular underlying byte buffer for performance.
+type Builder struct {
+ // B is the underlying byte buffer
+ B []byte
+
+ dd int // pos of last '..' appended to builder
+ abs bool // abs stores whether path passed to first .Append() is absolute
+ set bool // set stores whether b.abs has been set i.e. not first call to .Append()
+}
+
+// Reset resets the Builder object
+func (b *Builder) Reset() {
+ b.B = b.B[:0]
+ b.dd = 0
+ b.abs = false
+ b.set = false
+}
+
+// Len returns the number of accumulated bytes in the Builder
+func (b Builder) Len() int {
+ return len(b.B)
+}
+
+// Cap returns the capacity of the underlying Builder buffer
+func (b Builder) Cap() int {
+ return cap(b.B)
+}
+
+// Bytes returns the accumulated path bytes.
+func (b Builder) Bytes() []byte {
+ return b.B
+}
+
+// String returns the accumulated path string.
+func (b Builder) String() string {
+ return *(*string)(unsafe.Pointer(&b.B))
+}
+
+// Absolute returns whether current path is absolute (not relative).
+func (b Builder) Absolute() bool {
+ return b.abs
+}
+
+// SetAbsolute converts the current path to-or-from absolute.
+func (b *Builder) SetAbsolute(enabled bool) {
+ if !b.set {
+ // Ensure 1B avail
+ b.Guarantee(1)
+
+ if enabled {
+ // Set empty 'abs'
+ b.appendByte('/')
+ b.abs = true
+ } else {
+ // Set empty 'rel'
+ b.appendByte('.')
+ b.abs = false
+ }
+
+ b.set = true
+ return
+ }
+
+ if !enabled && b.abs {
+ // set && absolute
+ // -> update
+ b.abs = false
+
+ // If empty, set to '.' (empty rel path)
+ if len(b.B) == 0 || (len(b.B) == 1 && b.B[0] == '/') {
+ b.Guarantee(1)
+ b.B = b.B[:1]
+ b.B[0] = '.'
+ return
+ }
+
+ if b.B[0] != '/' {
+ // No need to change
+ return
+ }
+
+ if len(b.B) > 1 {
+ // Shift bytes 1 left
+ copy(b.B, b.B[1:])
+ }
+
+ // and drop the '/' prefix'
+ b.B = b.B[:len(b.B)-1]
+ } else if enabled && !b.abs {
+ // set && !absolute
+ // -> update
+ b.abs = true
+
+ // Ensure 1B avail
+ b.Guarantee(1)
+
+ // If empty, set to '/' (empty abs path)
+ if len(b.B) == 0 || (len(b.B) == 1 && b.B[0] == '.') {
+ b.Guarantee(1)
+ b.B = b.B[:1]
+ b.B[0] = '/'
+ return
+ }
+
+ // Increase length
+ l := len(b.B)
+ b.B = b.B[:l+1]
+
+ // Shift bytes 1 right
+ copy(b.B[1:], b.B[:l])
+
+ // Set first byte '/'
+ b.B[0] = '/'
+ }
+}
+
+// AppendBytes adds and cleans the supplied path bytes to the
+// builder's internal buffer, growing the buffer if necessary
+// to accomodate the extra path length.
+func (b *Builder) AppendBytes(path []byte) {
+ if len(path) == 0 {
+ return
+ }
+ b.Guarantee(len(path) + 1)
+ b.append(*(*string)(unsafe.Pointer(&b)))
+}
+
+// Append adds and cleans the supplied path string to the
+// builder's internal buffer, growing the buffer if necessary
+// to accomodate the extra path length.
+func (b *Builder) Append(path string) {
+ if len(path) == 0 {
+ return
+ }
+ b.Guarantee(len(path) + 1)
+ b.append(path)
+}
+
+// Clean creates the shortest possible functional equivalent
+// to the supplied path, resetting the builder before performing
+// this operation. The builder object is NOT reset after return.
+func (b *Builder) Clean(path string) string {
+ if path == "" {
+ return "."
+ }
+ b.Reset()
+ b.Guarantee(len(path) + 1)
+ b.append(path)
+ return string(b.B)
+}
+
+// Join connects and cleans multiple paths, resetting the builder before
+// performing this operation and returning the shortest possible combination
+// of all the supplied paths. The builder object is NOT reset after return.
+func (b *Builder) Join(elems ...string) string {
+ var size int
+ for _, elem := range elems {
+ size += len(elem)
+ }
+ if size == 0 {
+ return ""
+ }
+ b.Reset()
+ b.Guarantee(size + 1)
+ for _, elem := range elems {
+ if elem == "" {
+ continue
+ }
+ b.append(elem)
+ }
+ return string(b.B)
+}
+
+// append performs the main logic of 'Append()' but without an empty path check or preallocation.
+func (b *Builder) append(path string) {
+ if !b.set {
+ // Set if absolute or not
+ b.abs = path[0] == '/'
+ b.set = true
+ } else if !b.abs && len(b.B) == 1 && b.B[0] == '.' {
+ // Empty non-abs path segment, drop
+ // the period so not prefixed './'
+ b.B = b.B[:0]
+ }
+
+ for i := 0; i < len(path); {
+ switch {
+ // Empty path segment
+ case path[i] == '/':
+ i++
+
+ // Singular '.' path segment, treat as empty
+ case path[i] == '.' && (i+1 == len(path) || path[i+1] == '/'):
+ i++
+
+ // Backtrack segment
+ case path[i] == '.' && path[i+1] == '.' && (i+2 == len(path) || path[i+2] == '/'):
+ i += 2
+
+ switch {
+ // Check if it's possible to backtrack with
+ // our current state of the buffer. i.e. is
+ // our buffer length longer than the last
+ // '..' we placed?
+ case len(b.B) > b.dd:
+ b.backtrack()
+
+ // If we reached here, need to check if
+ // we can append '..' to the path buffer,
+ // which is ONLY when path is NOT absolute
+ case !b.abs:
+ if len(b.B) > 0 {
+ b.appendByte('/')
+ }
+ b.appendByte('.')
+ b.appendByte('.')
+ b.dd = len(b.B)
+ }
+
+ default:
+ if (b.abs && len(b.B) != 1) || (!b.abs && len(b.B) > 0) {
+ // Append path separator
+ b.appendByte('/')
+ }
+
+ // Append slice up to next '/'
+ i += b.appendSlice(path[i:])
+ }
+ }
+
+ if len(b.B) > 0 {
+ return
+ }
+
+ if b.abs {
+ // Empty absolute path => /
+ b.appendByte('/')
+ } else {
+ // Empty relative path => .
+ b.appendByte('.')
+ }
+}
+
+// Guarantee ensures there is at least the requested size
+// free bytes available in the buffer, reallocating if necessary
+func (b *Builder) Guarantee(size int) {
+ if size > cap(b.B)-len(b.B) {
+ nb := make([]byte, 2*cap(b.B)+size)
+ copy(nb, b.B)
+ b.B = nb[:len(b.B)]
+ }
+}
+
+// Truncate reduces the length of the buffer by the requested
+// number of bytes. If the byte slice is *effectively* empty,
+// i.e. absolute and "/" or relative and ".", it won't be truncated.
+func (b *Builder) Truncate(size int) {
+ if len(b.B) == 0 {
+ return
+ }
+
+ if len(b.B) == 1 && ((b.abs && b.B[0] == '/') ||
+ (!b.abs && b.B[0] == '.')) {
+ // *effectively* empty
+ return
+ }
+
+ // Truncate requested bytes
+ b.B = b.B[:len(b.B)-size]
+}
+
+// appendByte appends the supplied byte to the end of
+// the buffer. appending is achieved by continually reslicing the
+// buffer and setting the next byte-at-index, this is safe as guarantee()
+// will have been called beforehand
+func (b *Builder) appendByte(c byte) {
+ b.B = b.B[:len(b.B)+1]
+ b.B[len(b.B)-1] = c
+}
+
+// appendSlice appends the supplied string slice to
+// the end of the buffer and returns the number of indices
+// we were able to iterate before hitting a path separator '/'.
+// appending is achieved by continually reslicing the buffer
+// and setting the next byte-at-index, this is safe as guarantee()
+// will have been called beforehand
+func (b *Builder) appendSlice(slice string) int {
+ i := 0
+ for i < len(slice) && slice[i] != '/' {
+ b.B = b.B[:len(b.B)+1]
+ b.B[len(b.B)-1] = slice[i]
+ i++
+ }
+ return i
+}
+
+// backtrack reduces the end of the buffer back to the last
+// separating '/', or end of buffer
+func (b *Builder) backtrack() {
+ b.B = b.B[:len(b.B)-1]
+
+ for len(b.B)-1 > b.dd && b.B[len(b.B)-1] != '/' {
+ b.B = b.B[:len(b.B)-1]
+ }
+
+ if len(b.B) > 0 {
+ b.B = b.B[:len(b.B)-1]
+ }
+}
diff --git a/vendor/codeberg.org/gruf/go-store/v2/storage/block.go b/vendor/codeberg.org/gruf/go-store/v2/storage/block.go
@@ -676,10 +676,6 @@ func (st *BlockStorage) nodePathForKey(key string) (string, error) {
pb := util.GetPathBuilder()
defer util.PutPathBuilder(pb)
- // Append the nodepath to key
- pb.AppendString(st.nodePath)
- pb.AppendString(key)
-
// Return joined + cleaned node-path
return pb.Join(st.nodePath, key), nil
}
diff --git a/vendor/codeberg.org/gruf/go-store/v2/storage/disk.go b/vendor/codeberg.org/gruf/go-store/v2/storage/disk.go
@@ -394,16 +394,16 @@ func (st *DiskStorage) filepath(key string) (string, error) {
pb := util.GetPathBuilder()
defer util.PutPathBuilder(pb)
- // Generated joined root path
- pb.AppendString(st.path)
- pb.AppendString(key)
+ // Generate key path
+ pb.Append(st.path)
+ pb.Append(key)
// Check for dir traversal outside of root
- if isDirTraversal(st.path, pb.StringPtr()) {
+ if isDirTraversal(st.path, pb.String()) {
return "", ErrInvalidKey
}
- return pb.String(), nil
+ return string(pb.B), nil
}
// isDirTraversal will check if rootPlusPath is a dir traversal outside of root,
diff --git a/vendor/codeberg.org/gruf/go-store/v2/storage/fs.go b/vendor/codeberg.org/gruf/go-store/v2/storage/fs.go
@@ -5,7 +5,7 @@ import (
"os"
"syscall"
- "codeberg.org/gruf/go-fastpath"
+ "codeberg.org/gruf/go-fastpath/v2"
"codeberg.org/gruf/go-store/v2/util"
)
diff --git a/vendor/codeberg.org/gruf/go-store/v2/util/pool.go b/vendor/codeberg.org/gruf/go-store/v2/util/pool.go
@@ -1,16 +1,22 @@
package util
import (
- "codeberg.org/gruf/go-fastpath"
- "codeberg.org/gruf/go-pools"
+ "sync"
+
+ "codeberg.org/gruf/go-fastpath/v2"
)
// pathBuilderPool is the global fastpath.Builder pool.
-var pathBuilderPool = pools.NewPathBuilderPool(512)
+var pathBuilderPool = sync.Pool{
+ New: func() any {
+ return &fastpath.Builder{B: make([]byte, 0, 512)}
+ },
+}
// GetPathBuilder fetches a fastpath.Builder object from the pool.
func GetPathBuilder() *fastpath.Builder {
- return pathBuilderPool.Get()
+ pb, _ := pathBuilderPool.Get().(*fastpath.Builder)
+ return pb
}
// PutPathBuilder places supplied fastpath.Builder back in the pool.
diff --git a/vendor/modules.txt b/vendor/modules.txt
@@ -30,6 +30,9 @@ codeberg.org/gruf/go-fastcopy
# codeberg.org/gruf/go-fastpath v1.0.3
## explicit; go 1.14
codeberg.org/gruf/go-fastpath
+# codeberg.org/gruf/go-fastpath/v2 v2.0.0
+## explicit; go 1.14
+codeberg.org/gruf/go-fastpath/v2
# codeberg.org/gruf/go-hashenc v1.0.2
## explicit; go 1.16
codeberg.org/gruf/go-hashenc
@@ -58,7 +61,7 @@ codeberg.org/gruf/go-runners
# codeberg.org/gruf/go-sched v1.1.1
## explicit; go 1.19
codeberg.org/gruf/go-sched
-# codeberg.org/gruf/go-store/v2 v2.0.9
+# codeberg.org/gruf/go-store/v2 v2.0.10
## explicit; go 1.19
codeberg.org/gruf/go-store/v2/kv
codeberg.org/gruf/go-store/v2/storage