From 485ec6c780b4b6737d177a208cb5d66c53a222ba Mon Sep 17 00:00:00 2001 From: istae <14264581+istae@users.noreply.github.com> Date: Tue, 14 May 2024 00:19:12 +0300 Subject: [PATCH] chore: added extra logs before sleeping after db cmd (#4671) --- cmd/bee/cmd/db.go | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/cmd/bee/cmd/db.go b/cmd/bee/cmd/db.go index 4dec08f215d..5b07f43c571 100644 --- a/cmd/bee/cmd/db.go +++ b/cmd/bee/cmd/db.go @@ -132,7 +132,12 @@ func dbCompactCmd(cmd *cobra.Command) { if err != nil { logger.Error(err, "getting sleep value failed") } - defer func() { time.Sleep(d) }() + defer func() { + if d > 0 { + logger.Info("command has finished, sleeping...", "duration", d.String()) + time.Sleep(d) + } + }() dataDir, err := cmd.Flags().GetString(optionNameDataDir) if err != nil { @@ -266,7 +271,12 @@ func dbRepairReserve(cmd *cobra.Command) { if err != nil { logger.Error(err, "getting sleep value failed") } - defer func() { time.Sleep(d) }() + defer func() { + if d > 0 { + logger.Info("command has finished, sleeping...", "duration", d.String()) + time.Sleep(d) + } + }() db, err := storer.New(cmd.Context(), path.Join(dataDir, "localstore"), &storer.Options{ Logger: logger, @@ -781,6 +791,12 @@ func dbNukeCmd(cmd *cobra.Command) { if err != nil { logger.Error(err, "getting sleep value failed") } + defer func() { + if d > 0 { + logger.Info("command has finished, sleeping...", "duration", d.String()) + time.Sleep(d) + } + }() dataDir, err := cmd.Flags().GetString(optionNameDataDir) if err != nil { @@ -850,10 +866,6 @@ func dbNukeCmd(cmd *cobra.Command) { } } - logger.Info("nuke finished") - - time.Sleep(d) - return nil }} c.Flags().String(optionNameDataDir, "", "data directory")