summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2023-05-21 14:44:10 +0200
committerLibravatar GitHub <noreply@github.com>2023-05-21 14:44:10 +0200
commit68e54cbaa434dcffcf3a7f07b7d03a26e0afeb64 (patch)
treeb08b98ed32575f7b1b744c3b7ab05e4a569dd149
parent[bugfix] Fix incorrect default for empty emoji domain (#1803) (diff)
downloadgotosocial-68e54cbaa434dcffcf3a7f07b7d03a26e0afeb64.tar.xz
[bugfix] Start + stop caches properly for testrig + pruning (#1804)
* [bugfix] Start + stop caches properly for testrig + pruning * go fmt ./...
-rw-r--r--cmd/gotosocial/action/admin/media/prune/common.go7
-rw-r--r--cmd/gotosocial/action/testrig/testrig.go8
2 files changed, 9 insertions, 6 deletions
diff --git a/cmd/gotosocial/action/admin/media/prune/common.go b/cmd/gotosocial/action/admin/media/prune/common.go
index 54144504c..f6a782c69 100644
--- a/cmd/gotosocial/action/admin/media/prune/common.go
+++ b/cmd/gotosocial/action/admin/media/prune/common.go
@@ -37,7 +37,10 @@ type prune struct {
func setupPrune(ctx context.Context) (*prune, error) {
var state state.State
+
state.Caches.Init()
+ state.Caches.Start()
+
state.Workers.Start()
dbService, err := bundb.NewBunDBService(ctx, &state)
@@ -51,8 +54,6 @@ func setupPrune(ctx context.Context) (*prune, error) {
if err != nil {
return nil, fmt.Errorf("error creating storage backend: %w", err)
}
-
- state.DB = dbService
state.Storage = storage
//nolint:contextcheck
@@ -75,8 +76,8 @@ func (p *prune) shutdown(ctx context.Context) error {
return fmt.Errorf("error closing dbservice: %w", err)
}
- p.state.Caches.Stop()
p.state.Workers.Stop()
+ p.state.Caches.Stop()
return nil
}
diff --git a/cmd/gotosocial/action/testrig/testrig.go b/cmd/gotosocial/action/testrig/testrig.go
index b5d34e7c9..13e9a8f5b 100644
--- a/cmd/gotosocial/action/testrig/testrig.go
+++ b/cmd/gotosocial/action/testrig/testrig.go
@@ -56,12 +56,14 @@ var Start action.GTSAction = func(ctx context.Context) error {
return fmt.Errorf("error initializing tracing: %w", err)
}
- // Initialize caches
- state.Caches.Init()
+ // Initialize caches and database
+ state.DB = testrig.NewTestDB(&state)
+
+ // New test db inits caches so we don't need to do
+ // that twice, we can just start the initialized caches.
state.Caches.Start()
defer state.Caches.Stop()
- state.DB = testrig.NewTestDB(&state)
testrig.StandardDBSetup(state.DB, nil)
if os.Getenv("GTS_STORAGE_BACKEND") == "s3" {