Skip to content

Commit

Permalink
fix temp directories issue
Browse files Browse the repository at this point in the history
  • Loading branch information
harish551 committed Sep 20, 2024
1 parent 3884741 commit 3f36f7c
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions cmd/omniflixhubd/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ package cmd

import (
"errors"
"fmt"
"io"
"os"
"path/filepath"

"github.com/cosmos/cosmos-sdk/baseapp"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
Expand Down Expand Up @@ -73,6 +73,9 @@ func NewRootCmd() (*cobra.Command, params.EncodingConfig) {
if err := tempApp.Close(); err != nil {
panic(err)
}
if tempDir != app.DefaultNodeHome {
os.RemoveAll(tempDir)
}
}()

initClientCtx := client.Context{}.
Expand Down Expand Up @@ -179,7 +182,10 @@ func addModuleInitFlags(startCmd *cobra.Command) {
}

func tempDir() string {
dir := filepath.Join(os.TempDir(), "."+app.Name+"-temp")
dir, err := os.MkdirTemp("", "."+app.Name+"-temp")
if err != nil {
panic(fmt.Sprintf("failed creating temp directory: %s", err.Error()))
}
defer os.RemoveAll(dir)

return dir
Expand Down

0 comments on commit 3f36f7c

Please sign in to comment.