Skip to content

Commit

Permalink
remove temp dir when it's not needed anymore
Browse files Browse the repository at this point in the history
  • Loading branch information
bermuell committed Sep 19, 2024
1 parent 420ac1e commit 027afb2
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion cmd/gaiad/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cmd

import (
"errors"
"fmt"
"io"
"os"
"path/filepath"
Expand Down Expand Up @@ -80,6 +81,9 @@ func NewRootCmd() *cobra.Command {
if err := tempApplication.Close(); err != nil {
panic(err)
}
if tempDir != gaia.DefaultNodeHome {
os.RemoveAll(tempDir)
}
}()

initClientCtx := client.Context{}.
Expand Down Expand Up @@ -437,7 +441,7 @@ func (a appCreator) appExport(
var tempDir = func() string {
dir, err := os.MkdirTemp("", ".gaia")
if err != nil {
dir = gaia.DefaultNodeHome
panic(fmt.Sprintf("failed creating temp directory: %s", err.Error()))
}
defer os.RemoveAll(dir)

Expand Down

0 comments on commit 027afb2

Please sign in to comment.