Skip to content

Commit

Permalink
Merge pull request #2018 from CosmWasm/co/fix-tmp-dir
Browse files Browse the repository at this point in the history
Fix temp dir creation
  • Loading branch information
chipshort authored Oct 29, 2024
2 parents 4ca5cea + 8df66c4 commit 88cba83
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 0 additions & 1 deletion cmd/wasmd/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,6 @@ var tempDir = func() string {
if err != nil {
panic("failed to create temp dir: " + err.Error())
}
defer os.RemoveAll(dir)

return dir
}
6 changes: 5 additions & 1 deletion cmd/wasmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ func NewRootCmd() *cobra.Command {
cfg.Seal()
// we "pre"-instantiate the application for getting the injected/configured encoding configuration
// note, this is not necessary when using app wiring, as depinject can be directly used (see root_v2.go)
tempApp := app.NewWasmApp(log.NewNopLogger(), dbm.NewMemDB(), nil, false, simtestutil.NewAppOptionsWithFlagHome(tempDir()), []wasmkeeper.Option{})
temp := tempDir()
// cleanup temp dir after we are done with the tempApp, so we don't leave behind a
// new temporary directory for every invocation. See https://github.com/CosmWasm/wasmd/issues/2017
defer os.RemoveAll(temp)
tempApp := app.NewWasmApp(log.NewNopLogger(), dbm.NewMemDB(), nil, false, simtestutil.NewAppOptionsWithFlagHome(temp), []wasmkeeper.Option{})
encodingConfig := params.EncodingConfig{
InterfaceRegistry: tempApp.InterfaceRegistry(),
Codec: tempApp.AppCodec(),
Expand Down

0 comments on commit 88cba83

Please sign in to comment.