diff options
author | 2021-09-11 20:12:47 +0100 | |
---|---|---|
committer | 2021-09-11 20:12:47 +0100 | |
commit | e43a46e9822a05dd0345a7676e03285ddf83205e (patch) | |
tree | 72db13159e47d7815d001285fadb8225b1f7a571 /internal/processing | |
parent | documentation updates (#211) (diff) | |
download | gotosocial-e43a46e9822a05dd0345a7676e03285ddf83205e.tar.xz |
add git.iim.gay/grufwub/go-store for storage backend, replacing blob.Storage
Signed-off-by: kim (grufwub) <grufwub@gmail.com>
Diffstat (limited to 'internal/processing')
-rw-r--r-- | internal/processing/account/account_test.go | 4 | ||||
-rw-r--r-- | internal/processing/media/delete.go | 4 | ||||
-rw-r--r-- | internal/processing/media/getfile.go | 2 | ||||
-rw-r--r-- | internal/processing/media/media.go | 8 | ||||
-rw-r--r-- | internal/processing/processor.go | 11 | ||||
-rw-r--r-- | internal/processing/processor_test.go | 16 |
6 files changed, 22 insertions, 23 deletions
diff --git a/internal/processing/account/account_test.go b/internal/processing/account/account_test.go index 1884f6057..cfc7130ca 100644 --- a/internal/processing/account/account_test.go +++ b/internal/processing/account/account_test.go @@ -19,10 +19,10 @@ package account_test import ( + "git.iim.gay/grufwub/go-store/kv" "github.com/go-fed/activity/pub" "github.com/sirupsen/logrus" "github.com/stretchr/testify/suite" - "github.com/superseriousbusiness/gotosocial/internal/blob" "github.com/superseriousbusiness/gotosocial/internal/config" "github.com/superseriousbusiness/gotosocial/internal/db" "github.com/superseriousbusiness/gotosocial/internal/federation" @@ -43,7 +43,7 @@ type AccountStandardTestSuite struct { db db.DB log *logrus.Logger tc typeutils.TypeConverter - storage blob.Storage + storage *kv.KVStore mediaHandler media.Handler oauthServer oauth.Server fromClientAPIChan chan messages.FromClientAPI diff --git a/internal/processing/media/delete.go b/internal/processing/media/delete.go index 281ddba03..1c81417c3 100644 --- a/internal/processing/media/delete.go +++ b/internal/processing/media/delete.go @@ -24,14 +24,14 @@ func (p *processor) Delete(ctx context.Context, mediaAttachmentID string) gtserr // delete the thumbnail from storage if attachment.Thumbnail.Path != "" { - if err := p.storage.RemoveFileAt(attachment.Thumbnail.Path); err != nil { + if err := p.store.Delete(attachment.Thumbnail.Path); err != nil { errs = append(errs, fmt.Sprintf("remove thumbnail at path %s: %s", attachment.Thumbnail.Path, err)) } } // delete the file from storage if attachment.File.Path != "" { - if err := p.storage.RemoveFileAt(attachment.File.Path); err != nil { + if err := p.store.Delete(attachment.File.Path); err != nil { errs = append(errs, fmt.Sprintf("remove file at path %s: %s", attachment.File.Path, err)) } } diff --git a/internal/processing/media/getfile.go b/internal/processing/media/getfile.go index c9c9b556d..f0d27c841 100644 --- a/internal/processing/media/getfile.go +++ b/internal/processing/media/getfile.go @@ -110,7 +110,7 @@ func (p *processor) GetFile(ctx context.Context, account *gtsmodel.Account, form } } - bytes, err := p.storage.RetrieveFileFrom(storagePath) + bytes, err := p.store.Get(storagePath) if err != nil { return nil, gtserror.NewErrorNotFound(fmt.Errorf("error retrieving from storage: %s", err)) } diff --git a/internal/processing/media/media.go b/internal/processing/media/media.go index 6b88143e2..0f6711dae 100644 --- a/internal/processing/media/media.go +++ b/internal/processing/media/media.go @@ -21,9 +21,9 @@ package media import ( "context" + "git.iim.gay/grufwub/go-store/kv" "github.com/sirupsen/logrus" apimodel "github.com/superseriousbusiness/gotosocial/internal/api/model" - "github.com/superseriousbusiness/gotosocial/internal/blob" "github.com/superseriousbusiness/gotosocial/internal/config" "github.com/superseriousbusiness/gotosocial/internal/db" "github.com/superseriousbusiness/gotosocial/internal/gtserror" @@ -47,18 +47,18 @@ type processor struct { tc typeutils.TypeConverter config *config.Config mediaHandler media.Handler - storage blob.Storage + store *kv.KVStore db db.DB log *logrus.Logger } // New returns a new media processor. -func New(db db.DB, tc typeutils.TypeConverter, mediaHandler media.Handler, storage blob.Storage, config *config.Config, log *logrus.Logger) Processor { +func New(db db.DB, tc typeutils.TypeConverter, mediaHandler media.Handler, store *kv.KVStore, config *config.Config, log *logrus.Logger) Processor { return &processor{ tc: tc, config: config, mediaHandler: mediaHandler, - storage: storage, + store: store, db: db, log: log, } diff --git a/internal/processing/processor.go b/internal/processing/processor.go index 5dcdca152..c57d87889 100644 --- a/internal/processing/processor.go +++ b/internal/processing/processor.go @@ -23,9 +23,9 @@ import ( "net/http" "net/url" + "git.iim.gay/grufwub/go-store/kv" "github.com/sirupsen/logrus" apimodel "github.com/superseriousbusiness/gotosocial/internal/api/model" - "github.com/superseriousbusiness/gotosocial/internal/blob" "github.com/superseriousbusiness/gotosocial/internal/config" "github.com/superseriousbusiness/gotosocial/internal/db" "github.com/superseriousbusiness/gotosocial/internal/federation" @@ -234,7 +234,7 @@ type processor struct { tc typeutils.TypeConverter oauthServer oauth.Server mediaHandler media.Handler - storage blob.Storage + store *kv.KVStore timelineManager timeline.Manager db db.DB filter visibility.Filter @@ -251,8 +251,7 @@ type processor struct { } // NewProcessor returns a new Processor that uses the given federator and logger -func NewProcessor(config *config.Config, tc typeutils.TypeConverter, federator federation.Federator, oauthServer oauth.Server, mediaHandler media.Handler, storage blob.Storage, timelineManager timeline.Manager, db db.DB, log *logrus.Logger) Processor { - +func NewProcessor(config *config.Config, tc typeutils.TypeConverter, federator federation.Federator, oauthServer oauth.Server, mediaHandler media.Handler, store *kv.KVStore, timelineManager timeline.Manager, db db.DB, log *logrus.Logger) Processor { fromClientAPI := make(chan messages.FromClientAPI, 1000) fromFederator := make(chan messages.FromFederator, 1000) @@ -260,7 +259,7 @@ func NewProcessor(config *config.Config, tc typeutils.TypeConverter, federator f streamingProcessor := streaming.New(db, tc, oauthServer, config, log) accountProcessor := account.New(db, tc, mediaHandler, oauthServer, fromClientAPI, federator, config, log) adminProcessor := admin.New(db, tc, mediaHandler, fromClientAPI, config, log) - mediaProcessor := mediaProcessor.New(db, tc, mediaHandler, storage, config, log) + mediaProcessor := mediaProcessor.New(db, tc, mediaHandler, store, config, log) return &processor{ fromClientAPI: fromClientAPI, @@ -272,7 +271,7 @@ func NewProcessor(config *config.Config, tc typeutils.TypeConverter, federator f tc: tc, oauthServer: oauthServer, mediaHandler: mediaHandler, - storage: storage, + store: store, timelineManager: timelineManager, db: db, filter: visibility.NewFilter(db, log), diff --git a/internal/processing/processor_test.go b/internal/processing/processor_test.go index 7335b686d..59e2d6e97 100644 --- a/internal/processing/processor_test.go +++ b/internal/processing/processor_test.go @@ -21,9 +21,9 @@ package processing_test import ( "context" + "git.iim.gay/grufwub/go-store/kv" "github.com/sirupsen/logrus" "github.com/stretchr/testify/suite" - "github.com/superseriousbusiness/gotosocial/internal/blob" "github.com/superseriousbusiness/gotosocial/internal/config" "github.com/superseriousbusiness/gotosocial/internal/db" "github.com/superseriousbusiness/gotosocial/internal/federation" @@ -43,7 +43,7 @@ type ProcessingStandardTestSuite struct { config *config.Config db db.DB log *logrus.Logger - storage blob.Storage + store *kv.KVStore typeconverter typeutils.TypeConverter transportController transport.Controller federator federation.Federator @@ -89,12 +89,12 @@ func (suite *ProcessingStandardTestSuite) SetupTest() { suite.config = testrig.NewTestConfig() suite.db = testrig.NewTestDB() suite.log = testrig.NewTestLog() - suite.storage = testrig.NewTestStorage() + suite.store = testrig.NewTestStorage() suite.typeconverter = testrig.NewTestTypeConverter(suite.db) suite.transportController = testrig.NewTestTransportController(testrig.NewMockHTTPClient(nil), suite.db) - suite.federator = testrig.NewTestFederator(suite.db, suite.transportController, suite.storage) + suite.federator = testrig.NewTestFederator(suite.db, suite.transportController, suite.store) suite.oauthServer = testrig.NewTestOauthServer(suite.db) - suite.mediaHandler = testrig.NewTestMediaHandler(suite.db, suite.storage) + suite.mediaHandler = testrig.NewTestMediaHandler(suite.db, suite.store) suite.timelineManager = testrig.NewTestTimelineManager(suite.db) suite.processor = processing.NewProcessor( @@ -103,13 +103,13 @@ func (suite *ProcessingStandardTestSuite) SetupTest() { suite.federator, suite.oauthServer, suite.mediaHandler, - suite.storage, + suite.store, suite.timelineManager, suite.db, suite.log) testrig.StandardDBSetup(suite.db, suite.testAccounts) - testrig.StandardStorageSetup(suite.storage, "../../testrig/media") + testrig.StandardStorageSetup(suite.store, "../../testrig/media") if err := suite.processor.Start(context.Background()); err != nil { panic(err) } @@ -117,7 +117,7 @@ func (suite *ProcessingStandardTestSuite) SetupTest() { func (suite *ProcessingStandardTestSuite) TearDownTest() { testrig.StandardDBTeardown(suite.db) - testrig.StandardStorageTeardown(suite.storage) + testrig.StandardStorageTeardown(suite.store) if err := suite.processor.Stop(); err != nil { panic(err) } |