From 319c307b11f9604afc164d8a52205619a9e8cdcf Mon Sep 17 00:00:00 2001 From: Tulip Blossom Date: Mon, 16 Dec 2024 02:45:23 -0300 Subject: [PATCH] fix: appease the linting gods --- cmd/update.go | 2 +- pkg/session/session.go | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/cmd/update.go b/cmd/update.go index e8fbb31..055efad 100644 --- a/cmd/update.go +++ b/cmd/update.go @@ -84,7 +84,7 @@ func Update(cmd *cobra.Command, args []string) { distroboxUpdater.Config.Enabled = err == nil distroboxUpdater.SetUsers(users) - mainSystemDriver, mainSystemDriverConfig, _, err := system.InitializeSystemDriver(*initConfiguration) + mainSystemDriver, mainSystemDriverConfig, _, _ := system.InitializeSystemDriver(*initConfiguration) enableUpd, err := mainSystemDriver.Check() if err != nil { diff --git a/pkg/session/session.go b/pkg/session/session.go index 68f534a..5f9bacc 100644 --- a/pkg/session/session.go +++ b/pkg/session/session.go @@ -2,6 +2,7 @@ package session import ( "bufio" + "context" "fmt" "io" "log/slog" @@ -26,13 +27,17 @@ func RunLog(logger *slog.Logger, level slog.Level, command *exec.Cmd) ([]byte, e stderr, _ := command.StderrPipe() multiReader := io.MultiReader(stdout, stderr) - command.Start() + if err := command.Wait(); err != nil { + logger.Warn("Error occoured starting external command", slog.Any("error", err)) + } scanner := bufio.NewScanner(multiReader) scanner.Split(bufio.ScanLines) for scanner.Scan() { - logger.With(slog.Bool("subcommand", true)).Log(nil, level, scanner.Text()) + logger.With(slog.Bool("subcommand", true)).Log(context.TODO(), level, scanner.Text()) + } + if err := command.Wait(); err != nil { + logger.Warn("Error occoured while waiting for external command", slog.Any("error", err)) } - command.Wait() return scanner.Bytes(), scanner.Err() }