mirror of
https://github.com/superseriousbusiness/gotosocial
synced 2025-06-05 21:59:39 +02:00
[dependencies] update go-store, go-mutexes (#422)
* update go-store, go-mutexes Signed-off-by: kim <grufwub@gmail.com> * update vendored code Signed-off-by: kim <grufwub@gmail.com>
This commit is contained in:
2
vendor/codeberg.org/gruf/go-store/kv/store.go
generated
vendored
2
vendor/codeberg.org/gruf/go-store/kv/store.go
generated
vendored
@@ -45,7 +45,7 @@ func OpenStorage(storage storage.Storage) (*KVStore, error) {
|
||||
|
||||
// Return new KVStore
|
||||
return &KVStore{
|
||||
mutex: mutexes.NewMap(-1),
|
||||
mutex: mutexes.NewMap(-1, -1),
|
||||
storage: storage,
|
||||
}, nil
|
||||
}
|
||||
|
31
vendor/codeberg.org/gruf/go-store/storage/disk.go
generated
vendored
31
vendor/codeberg.org/gruf/go-store/storage/disk.go
generated
vendored
@@ -10,7 +10,7 @@ import (
|
||||
"syscall"
|
||||
|
||||
"codeberg.org/gruf/go-bytes"
|
||||
"codeberg.org/gruf/go-pools"
|
||||
"codeberg.org/gruf/go-fastcopy"
|
||||
"codeberg.org/gruf/go-store/util"
|
||||
)
|
||||
|
||||
@@ -81,10 +81,10 @@ func getDiskConfig(cfg *DiskConfig) DiskConfig {
|
||||
|
||||
// DiskStorage is a Storage implementation that stores directly to a filesystem
|
||||
type DiskStorage struct {
|
||||
path string // path is the root path of this store
|
||||
bufp pools.BufferPool // bufp is the buffer pool for this DiskStorage
|
||||
config DiskConfig // cfg is the supplied configuration for this store
|
||||
lock *Lock // lock is the opened lockfile for this storage instance
|
||||
path string // path is the root path of this store
|
||||
cppool fastcopy.CopyPool // cppool is the prepared io copier with buffer pool
|
||||
config DiskConfig // cfg is the supplied configuration for this store
|
||||
lock *Lock // lock is the opened lockfile for this storage instance
|
||||
}
|
||||
|
||||
// OpenFile opens a DiskStorage instance for given folder path and configuration
|
||||
@@ -147,13 +147,17 @@ func OpenFile(path string, cfg *DiskConfig) (*DiskStorage, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Return new DiskStorage
|
||||
return &DiskStorage{
|
||||
// Prepare DiskStorage
|
||||
st := &DiskStorage{
|
||||
path: storePath,
|
||||
bufp: pools.NewBufferPool(config.WriteBufSize),
|
||||
config: config,
|
||||
lock: lock,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Set copypool buffer size
|
||||
st.cppool.Buffer(config.WriteBufSize)
|
||||
|
||||
return st, nil
|
||||
}
|
||||
|
||||
// Clean implements Storage.Clean()
|
||||
@@ -271,13 +275,8 @@ func (st *DiskStorage) WriteStream(key string, r io.Reader) error {
|
||||
}
|
||||
defer cFile.Close()
|
||||
|
||||
// Acquire write buffer
|
||||
buf := st.bufp.Get()
|
||||
defer st.bufp.Put(buf)
|
||||
buf.Grow(st.config.WriteBufSize)
|
||||
|
||||
// Copy reader to file
|
||||
_, err = io.CopyBuffer(cFile, r, buf.B)
|
||||
// Copy provided reader to file
|
||||
_, err = st.cppool.Copy(cFile, r)
|
||||
return err
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user