mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-12-11 02:38:06 -06:00
[chore] bump gruf/go-store to v2 (#953)
* [chore] bump gruf/go-store to v2 * no more boobs
This commit is contained in:
parent
a9addb59b6
commit
bcb80d3ff4
105 changed files with 12360 additions and 4859 deletions
|
|
@ -138,7 +138,7 @@ func (suite *MediaCreateTestSuite) TestMediaCreateSuccessful() {
|
|||
|
||||
// see what's in storage *before* the request
|
||||
storageKeysBeforeRequest := []string{}
|
||||
iter, err := suite.storage.KVStore.Iterator(nil)
|
||||
iter, err := suite.storage.KVStore.Iterator(context.Background(), nil)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
|
@ -170,7 +170,7 @@ func (suite *MediaCreateTestSuite) TestMediaCreateSuccessful() {
|
|||
|
||||
// check what's in storage *after* the request
|
||||
storageKeysAfterRequest := []string{}
|
||||
iter, err = suite.storage.KVStore.Iterator(nil)
|
||||
iter, err = suite.storage.KVStore.Iterator(context.Background(), nil)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
|
@ -232,7 +232,7 @@ func (suite *MediaCreateTestSuite) TestMediaCreateSuccessfulV2() {
|
|||
|
||||
// see what's in storage *before* the request
|
||||
storageKeysBeforeRequest := []string{}
|
||||
iter, err := suite.storage.KVStore.Iterator(nil)
|
||||
iter, err := suite.storage.KVStore.Iterator(context.Background(), nil)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
|
@ -264,7 +264,7 @@ func (suite *MediaCreateTestSuite) TestMediaCreateSuccessfulV2() {
|
|||
|
||||
// check what's in storage *after* the request
|
||||
storageKeysAfterRequest := []string{}
|
||||
iter, err = suite.storage.KVStore.Iterator(nil)
|
||||
iter, err = suite.storage.KVStore.Iterator(context.Background(), nil)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,8 +24,8 @@ import (
|
|||
"fmt"
|
||||
"path"
|
||||
|
||||
"codeberg.org/gruf/go-store/kv"
|
||||
"codeberg.org/gruf/go-store/storage"
|
||||
"codeberg.org/gruf/go-store/v2/kv"
|
||||
"codeberg.org/gruf/go-store/v2/storage"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/config"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/log"
|
||||
|
|
@ -34,13 +34,13 @@ import (
|
|||
|
||||
func init() {
|
||||
deleteAttachment := func(ctx context.Context, l log.Entry, a *gtsmodel.MediaAttachment, s *kv.KVStore, tx bun.Tx) {
|
||||
if err := s.Delete(a.File.Path); err != nil && err != storage.ErrNotFound {
|
||||
if err := s.Delete(ctx, a.File.Path); err != nil && err != storage.ErrNotFound {
|
||||
l.Errorf("error removing file %s: %s", a.File.Path, err)
|
||||
} else {
|
||||
l.Debugf("deleted %s", a.File.Path)
|
||||
}
|
||||
|
||||
if err := s.Delete(a.Thumbnail.Path); err != nil && err != storage.ErrNotFound {
|
||||
if err := s.Delete(ctx, a.Thumbnail.Path); err != nil && err != storage.ErrNotFound {
|
||||
l.Errorf("error removing file %s: %s", a.Thumbnail.Path, err)
|
||||
} else {
|
||||
l.Debugf("deleted %s", a.Thumbnail.Path)
|
||||
|
|
@ -70,7 +70,7 @@ func init() {
|
|||
}
|
||||
|
||||
return db.RunInTx(ctx, nil, func(ctx context.Context, tx bun.Tx) error {
|
||||
s, err := kv.OpenFile(storageBasePath, &storage.DiskConfig{
|
||||
s, err := kv.OpenDisk(storageBasePath, &storage.DiskConfig{
|
||||
LockFile: path.Join(storageBasePath, "store.lock"),
|
||||
})
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -27,8 +27,8 @@ import (
|
|||
"path"
|
||||
"testing"
|
||||
|
||||
"codeberg.org/gruf/go-store/kv"
|
||||
"codeberg.org/gruf/go-store/storage"
|
||||
"codeberg.org/gruf/go-store/v2/kv"
|
||||
"codeberg.org/gruf/go-store/v2/storage"
|
||||
"github.com/stretchr/testify/suite"
|
||||
gtsmodel "github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/media"
|
||||
|
|
@ -927,7 +927,7 @@ func (suite *ManagerTestSuite) TestSimpleJpegProcessBlockingWithDiskStorage() {
|
|||
temp := fmt.Sprintf("%s/gotosocial-test", os.TempDir())
|
||||
defer os.RemoveAll(temp)
|
||||
|
||||
diskStorage, err := kv.OpenFile(temp, &storage.DiskConfig{
|
||||
diskStorage, err := kv.OpenDisk(temp, &storage.DiskConfig{
|
||||
LockFile: path.Join(temp, "store.lock"),
|
||||
})
|
||||
if err != nil {
|
||||
|
|
@ -974,7 +974,7 @@ func (suite *ManagerTestSuite) TestSimpleJpegProcessBlockingWithDiskStorage() {
|
|||
suite.NotNil(dbAttachment)
|
||||
|
||||
// make sure the processed file is in storage
|
||||
processedFullBytes, err := diskStorage.Get(attachment.File.Path)
|
||||
processedFullBytes, err := diskStorage.Get(ctx, attachment.File.Path)
|
||||
suite.NoError(err)
|
||||
suite.NotEmpty(processedFullBytes)
|
||||
|
||||
|
|
@ -987,7 +987,7 @@ func (suite *ManagerTestSuite) TestSimpleJpegProcessBlockingWithDiskStorage() {
|
|||
suite.Equal(processedFullBytesExpected, processedFullBytes)
|
||||
|
||||
// now do the same for the thumbnail and make sure it's what we expected
|
||||
processedThumbnailBytes, err := diskStorage.Get(attachment.Thumbnail.Path)
|
||||
processedThumbnailBytes, err := diskStorage.Get(ctx, attachment.Thumbnail.Path)
|
||||
suite.NoError(err)
|
||||
suite.NotEmpty(processedThumbnailBytes)
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ import (
|
|||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
gostore "codeberg.org/gruf/go-store/storage"
|
||||
gostore "codeberg.org/gruf/go-store/v2/storage"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/config"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/db"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ package media
|
|||
import (
|
||||
"context"
|
||||
|
||||
"codeberg.org/gruf/go-store/storage"
|
||||
"codeberg.org/gruf/go-store/v2/storage"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/db"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/log"
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ import (
|
|||
"context"
|
||||
"testing"
|
||||
|
||||
"codeberg.org/gruf/go-store/storage"
|
||||
"codeberg.org/gruf/go-store/v2/storage"
|
||||
"github.com/stretchr/testify/suite"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/db"
|
||||
)
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ import (
|
|||
"context"
|
||||
"fmt"
|
||||
|
||||
"codeberg.org/gruf/go-store/storage"
|
||||
"codeberg.org/gruf/go-store/v2/storage"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/db"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/log"
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ import (
|
|||
"os"
|
||||
"testing"
|
||||
|
||||
"codeberg.org/gruf/go-store/storage"
|
||||
"codeberg.org/gruf/go-store/v2/storage"
|
||||
"github.com/stretchr/testify/suite"
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ import (
|
|||
"context"
|
||||
"fmt"
|
||||
|
||||
"codeberg.org/gruf/go-store/storage"
|
||||
"codeberg.org/gruf/go-store/v2/storage"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/db"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/log"
|
||||
|
|
|
|||
|
|
@ -23,8 +23,8 @@ import (
|
|||
"io"
|
||||
"net/url"
|
||||
|
||||
"codeberg.org/gruf/go-store/kv"
|
||||
"codeberg.org/gruf/go-store/storage"
|
||||
"codeberg.org/gruf/go-store/v2/kv"
|
||||
"codeberg.org/gruf/go-store/v2/storage"
|
||||
)
|
||||
|
||||
type Local struct {
|
||||
|
|
@ -32,15 +32,15 @@ type Local struct {
|
|||
}
|
||||
|
||||
func (l *Local) Get(ctx context.Context, key string) ([]byte, error) {
|
||||
return l.KVStore.Get(key)
|
||||
return l.KVStore.Get(ctx, key)
|
||||
}
|
||||
|
||||
func (l *Local) GetStream(ctx context.Context, key string) (io.ReadCloser, error) {
|
||||
return l.KVStore.GetStream(key)
|
||||
return l.KVStore.GetStream(ctx, key)
|
||||
}
|
||||
|
||||
func (l *Local) PutStream(ctx context.Context, key string, r io.Reader) error {
|
||||
err := l.KVStore.PutStream(key, r)
|
||||
err := l.KVStore.PutStream(ctx, key, r)
|
||||
if err == storage.ErrAlreadyExists {
|
||||
return ErrAlreadyExists
|
||||
}
|
||||
|
|
@ -48,7 +48,7 @@ func (l *Local) PutStream(ctx context.Context, key string, r io.Reader) error {
|
|||
}
|
||||
|
||||
func (l *Local) Put(ctx context.Context, key string, value []byte) error {
|
||||
err := l.KVStore.Put(key, value)
|
||||
err := l.KVStore.Put(ctx, key, value)
|
||||
if err == storage.ErrAlreadyExists {
|
||||
return ErrAlreadyExists
|
||||
}
|
||||
|
|
@ -56,7 +56,7 @@ func (l *Local) Put(ctx context.Context, key string, value []byte) error {
|
|||
}
|
||||
|
||||
func (l *Local) Delete(ctx context.Context, key string) error {
|
||||
return l.KVStore.Delete(key)
|
||||
return l.KVStore.Delete(ctx, key)
|
||||
}
|
||||
|
||||
func (l *Local) URL(ctx context.Context, key string) *url.URL {
|
||||
|
|
|
|||
|
|
@ -26,8 +26,8 @@ import (
|
|||
"net/url"
|
||||
"path"
|
||||
|
||||
"codeberg.org/gruf/go-store/kv"
|
||||
"codeberg.org/gruf/go-store/storage"
|
||||
"codeberg.org/gruf/go-store/v2/kv"
|
||||
"codeberg.org/gruf/go-store/v2/storage"
|
||||
"github.com/minio/minio-go/v7"
|
||||
"github.com/minio/minio-go/v7/pkg/credentials"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/config"
|
||||
|
|
@ -60,7 +60,7 @@ func AutoConfig() (Driver, error) {
|
|||
return NewS3(mc, config.GetStorageS3BucketName()), nil
|
||||
case "local":
|
||||
storageBasePath := config.GetStorageLocalBasePath()
|
||||
storage, err := kv.OpenFile(storageBasePath, &storage.DiskConfig{
|
||||
storage, err := kv.OpenDisk(storageBasePath, &storage.DiskConfig{
|
||||
// Put the store lockfile in the storage dir itself.
|
||||
// Normally this would not be safe, since we could end up
|
||||
// overwriting the lockfile if we store a file called 'store.lock'.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue