From c28d1af877efe47dafa9880f06d18ebfc4572252 Mon Sep 17 00:00:00 2001 From: kolaente Date: Mon, 4 Sep 2023 11:22:50 +0200 Subject: [PATCH] fix(cmd): do not initialize asnyc operations when running certain cli commands --- pkg/cmd/dump.go | 2 +- pkg/cmd/index.go | 2 +- pkg/cmd/restore.go | 2 +- pkg/initialize/init.go | 15 ++++++++++----- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/pkg/cmd/dump.go b/pkg/cmd/dump.go index a6690957a1e..6572c17d347 100644 --- a/pkg/cmd/dump.go +++ b/pkg/cmd/dump.go @@ -33,7 +33,7 @@ var dumpCmd = &cobra.Command{ Use: "dump", Short: "Dump all vikunja data into a zip file. Includes config, files and db.", PreRun: func(cmd *cobra.Command, args []string) { - initialize.FullInit() + initialize.FullInitWithoutAsync() }, Run: func(cmd *cobra.Command, args []string) { filename := "vikunja-dump_" + time.Now().Format("2006-01-02_15-03-05") + ".zip" diff --git a/pkg/cmd/index.go b/pkg/cmd/index.go index 0779cb30909..50f674c67f8 100644 --- a/pkg/cmd/index.go +++ b/pkg/cmd/index.go @@ -32,7 +32,7 @@ var indexCmd = &cobra.Command{ Use: "index", Short: "Reindex all of Vikunja's data into Typesense. This will remove any existing index.", PreRun: func(cmd *cobra.Command, args []string) { - initialize.FullInit() + initialize.FullInitWithoutAsync() }, Run: func(cmd *cobra.Command, args []string) { if !config.TypesenseEnabled.GetBool() { diff --git a/pkg/cmd/restore.go b/pkg/cmd/restore.go index 2660c4297bd..2b8d3ee93de 100644 --- a/pkg/cmd/restore.go +++ b/pkg/cmd/restore.go @@ -32,7 +32,7 @@ var restoreCmd = &cobra.Command{ Short: "Restores all vikunja data from a vikunja dump.", Args: cobra.ExactArgs(1), PreRun: func(cmd *cobra.Command, args []string) { - initialize.FullInit() + initialize.FullInitWithoutAsync() }, Run: func(cmd *cobra.Command, args []string) { if err := dump.Restore(args[0]); err != nil { diff --git a/pkg/initialize/init.go b/pkg/initialize/init.go index 550781d2eb9..6d9ef48692f 100644 --- a/pkg/initialize/init.go +++ b/pkg/initialize/init.go @@ -17,6 +17,8 @@ package initialize import ( + "code.vikunja.io/api/pkg/mail" + "code.vikunja.io/api/pkg/migration" "time" "code.vikunja.io/api/pkg/config" @@ -24,8 +26,6 @@ import ( "code.vikunja.io/api/pkg/events" "code.vikunja.io/api/pkg/files" "code.vikunja.io/api/pkg/log" - "code.vikunja.io/api/pkg/mail" - "code.vikunja.io/api/pkg/migration" "code.vikunja.io/api/pkg/models" "code.vikunja.io/api/pkg/modules/auth/openid" "code.vikunja.io/api/pkg/modules/keyvalue" @@ -60,9 +60,8 @@ func InitEngines() { } } -// FullInit initializes all kinds of things in the right order -func FullInit() { - +// FullInitWithoutAsync does a full init without any async handlers (cron or events) +func FullInitWithoutAsync() { LightInit() // Initialize the files handler @@ -79,6 +78,12 @@ func FullInit() { // Start the mail daemon mail.StartMailDaemon() +} + +// FullInit initializes all kinds of things in the right order +func FullInit() { + + FullInitWithoutAsync() // Start the cron cron.Init()