diff --git a/internal/cliactions/server/server.go b/internal/cliactions/server/server.go index bc9759760..e2f6a24b4 100644 --- a/internal/cliactions/server/server.go +++ b/internal/cliactions/server/server.go @@ -76,8 +76,8 @@ var Start cliactions.GTSAction = func(ctx context.Context, c *config.Config, log return fmt.Errorf("error creating router: %s", err) } - // Create new storage backend - store, err := kv.OpenFile(c.StorageConfig.BasePath, nil) + // Open the storage backend + storage, err := kv.OpenFile(c.StorageConfig.BasePath, nil) if err != nil { return fmt.Errorf("error creating storage backend: %s", err) } @@ -87,11 +87,11 @@ var Start cliactions.GTSAction = func(ctx context.Context, c *config.Config, log timelineManager := timelineprocessing.NewManager(dbService, typeConverter, c, log) // build backend handlers - mediaHandler := media.New(c, dbService, store, log) + mediaHandler := media.New(c, dbService, storage, log) oauthServer := oauth.New(dbService, log) transportController := transport.NewController(c, dbService, &federation.Clock{}, http.DefaultClient, log) federator := federation.NewFederator(dbService, federatingDB, transportController, c, log, typeConverter, mediaHandler) - processor := processing.NewProcessor(c, typeConverter, federator, oauthServer, mediaHandler, store, timelineManager, dbService, log) + processor := processing.NewProcessor(c, typeConverter, federator, oauthServer, mediaHandler, storage, timelineManager, dbService, log) if err := processor.Start(ctx); err != nil { return fmt.Errorf("error starting processor: %s", err) } diff --git a/internal/media/handler.go b/internal/media/handler.go index f2450bbc0..058337ecf 100644 --- a/internal/media/handler.go +++ b/internal/media/handler.go @@ -84,19 +84,19 @@ type Handler interface { } type mediaHandler struct { - config *config.Config - db db.DB - store *kv.KVStore - log *logrus.Logger + config *config.Config + db db.DB + storage *kv.KVStore + log *logrus.Logger } // New returns a new handler with the given config, db, storage, and logger -func New(config *config.Config, database db.DB, store *kv.KVStore, log *logrus.Logger) Handler { +func New(config *config.Config, database db.DB, storage *kv.KVStore, log *logrus.Logger) Handler { return &mediaHandler{ - config: config, - db: database, - store: store, - log: log, + config: config, + db: database, + storage: storage, + log: log, } } @@ -257,12 +257,12 @@ func (mh *mediaHandler) ProcessLocalEmoji(ctx context.Context, emojiBytes []byte emojiStaticPath := fmt.Sprintf("%s/%s/%s/%s/%s.png", mh.config.StorageConfig.BasePath, instanceAccount.ID, Emoji, Static, newEmojiID) // Store the original emoji - if err := mh.store.Put(emojiPath, original.image); err != nil { + if err := mh.storage.Put(emojiPath, original.image); err != nil { return nil, fmt.Errorf("storage error: %s", err) } // Store the static emoji - if err := mh.store.Put(emojiStaticPath, static.image); err != nil { + if err := mh.storage.Put(emojiStaticPath, static.image); err != nil { return nil, fmt.Errorf("storage error: %s", err) } diff --git a/internal/media/processicon.go b/internal/media/processicon.go index 9ef4d77ec..b6b113b0c 100644 --- a/internal/media/processicon.go +++ b/internal/media/processicon.go @@ -85,13 +85,13 @@ func (mh *mediaHandler) processHeaderOrAvi(imageBytes []byte, contentType string // we store the original... originalPath := fmt.Sprintf("%s/%s/%s/%s/%s.%s", mh.config.StorageConfig.BasePath, accountID, mediaType, Original, newMediaID, extension) - if err := mh.store.Put(originalPath, original.image); err != nil { + if err := mh.storage.Put(originalPath, original.image); err != nil { return nil, fmt.Errorf("storage error: %s", err) } // and a thumbnail... smallPath := fmt.Sprintf("%s/%s/%s/%s/%s.%s", mh.config.StorageConfig.BasePath, accountID, mediaType, Small, newMediaID, extension) - if err := mh.store.Put(smallPath, small.image); err != nil { + if err := mh.storage.Put(smallPath, small.image); err != nil { return nil, fmt.Errorf("storage error: %s", err) } diff --git a/internal/media/processimage.go b/internal/media/processimage.go index 3e7e60fb7..e06ad8d14 100644 --- a/internal/media/processimage.go +++ b/internal/media/processimage.go @@ -73,13 +73,13 @@ func (mh *mediaHandler) processImageAttachment(data []byte, minAttachment *gtsmo // we store the original... originalPath := fmt.Sprintf("%s/%s/%s/%s/%s.%s", mh.config.StorageConfig.BasePath, minAttachment.AccountID, Attachment, Original, newMediaID, extension) - if err := mh.store.Put(originalPath, original.image); err != nil { + if err := mh.storage.Put(originalPath, original.image); err != nil { return nil, fmt.Errorf("storage error: %s", err) } // and a thumbnail... smallPath := fmt.Sprintf("%s/%s/%s/%s/%s.jpeg", mh.config.StorageConfig.BasePath, minAttachment.AccountID, Attachment, Small, newMediaID) // all thumbnails/smalls are encoded as jpeg - if err := mh.store.Put(smallPath, small.image); err != nil { + if err := mh.storage.Put(smallPath, small.image); err != nil { return nil, fmt.Errorf("storage error: %s", err) } diff --git a/internal/processing/media/delete.go b/internal/processing/media/delete.go index 1c81417c3..e99b4e950 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.store.Delete(attachment.Thumbnail.Path); err != nil { + if err := p.storage.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.store.Delete(attachment.File.Path); err != nil { + if err := p.storage.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 f0d27c841..3cfdbe56b 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.store.Get(storagePath) + bytes, err := p.storage.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 0f6711dae..4c8416483 100644 --- a/internal/processing/media/media.go +++ b/internal/processing/media/media.go @@ -47,18 +47,18 @@ type processor struct { tc typeutils.TypeConverter config *config.Config mediaHandler media.Handler - store *kv.KVStore + storage *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, store *kv.KVStore, config *config.Config, log *logrus.Logger) Processor { +func New(db db.DB, tc typeutils.TypeConverter, mediaHandler media.Handler, storage *kv.KVStore, config *config.Config, log *logrus.Logger) Processor { return &processor{ tc: tc, config: config, mediaHandler: mediaHandler, - store: store, + storage: storage, db: db, log: log, } diff --git a/internal/processing/processor.go b/internal/processing/processor.go index c57d87889..bc6e6511b 100644 --- a/internal/processing/processor.go +++ b/internal/processing/processor.go @@ -234,7 +234,7 @@ type processor struct { tc typeutils.TypeConverter oauthServer oauth.Server mediaHandler media.Handler - store *kv.KVStore + storage *kv.KVStore timelineManager timeline.Manager db db.DB filter visibility.Filter @@ -251,7 +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, store *kv.KVStore, 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, storage *kv.KVStore, timelineManager timeline.Manager, db db.DB, log *logrus.Logger) Processor { fromClientAPI := make(chan messages.FromClientAPI, 1000) fromFederator := make(chan messages.FromFederator, 1000) @@ -259,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, store, config, log) + mediaProcessor := mediaProcessor.New(db, tc, mediaHandler, storage, config, log) return &processor{ fromClientAPI: fromClientAPI, @@ -271,7 +271,7 @@ func NewProcessor(config *config.Config, tc typeutils.TypeConverter, federator f tc: tc, oauthServer: oauthServer, mediaHandler: mediaHandler, - store: store, + storage: storage, timelineManager: timelineManager, db: db, filter: visibility.NewFilter(db, log), diff --git a/internal/processing/processor_test.go b/internal/processing/processor_test.go index 59e2d6e97..daaf46726 100644 --- a/internal/processing/processor_test.go +++ b/internal/processing/processor_test.go @@ -43,7 +43,7 @@ type ProcessingStandardTestSuite struct { config *config.Config db db.DB log *logrus.Logger - store *kv.KVStore + storage *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.store = testrig.NewTestStorage() + suite.storage = 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.store) + suite.federator = testrig.NewTestFederator(suite.db, suite.transportController, suite.storage) suite.oauthServer = testrig.NewTestOauthServer(suite.db) - suite.mediaHandler = testrig.NewTestMediaHandler(suite.db, suite.store) + suite.mediaHandler = testrig.NewTestMediaHandler(suite.db, suite.storage) 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.store, + suite.storage, suite.timelineManager, suite.db, suite.log) testrig.StandardDBSetup(suite.db, suite.testAccounts) - testrig.StandardStorageSetup(suite.store, "../../testrig/media") + testrig.StandardStorageSetup(suite.storage, "../../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.store) + testrig.StandardStorageTeardown(suite.storage) if err := suite.processor.Stop(); err != nil { panic(err) }