From d1ef5b6fc1a479e171f0eb1189d384baca0dbcce Mon Sep 17 00:00:00 2001 From: mmsqe Date: Thu, 9 Nov 2023 11:24:05 +0800 Subject: [PATCH 1/3] fix: add os.IsExist check for err --- CHANGELOG.md | 1 + cmd/appstate.go | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d5a46901d..5b28742fa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,7 @@ * [\#1231](https://github.com/cosmos/relayer/pull/1231) Reduce get bech32 prefix when get signer. * [\#1302](https://github.com/cosmos/relayer/pull/1302) Avoid packet get relayed when estimated gas is higher than max gas. * [\#1303](https://github.com/cosmos/relayer/pull/1303) Add missing max gas amount on txf to avoid estimate less gas when simualte runTx. +* [\#](https://github.com/cosmos/relayer/pull/) Ignore only file not exist error when loadConfigFile. ## v0.9.3 diff --git a/cmd/appstate.go b/cmd/appstate.go index 738e9af40..96e2969d5 100644 --- a/cmd/appstate.go +++ b/cmd/appstate.go @@ -40,7 +40,10 @@ func (a *appState) loadConfigFile(ctx context.Context) error { if _, err := os.Stat(cfgPath); err != nil { // don't return error if file doesn't exist - return nil + if os.IsExist(err) { + err = nil + } + return err } // read the config file bytes From 478a46be4e9ba91017944537d5c55a68acca882f Mon Sep 17 00:00:00 2001 From: mmsqe Date: Thu, 9 Nov 2023 11:27:06 +0800 Subject: [PATCH 2/3] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5b28742fa..0dd3bce1f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,7 +25,7 @@ * [\#1231](https://github.com/cosmos/relayer/pull/1231) Reduce get bech32 prefix when get signer. * [\#1302](https://github.com/cosmos/relayer/pull/1302) Avoid packet get relayed when estimated gas is higher than max gas. * [\#1303](https://github.com/cosmos/relayer/pull/1303) Add missing max gas amount on txf to avoid estimate less gas when simualte runTx. -* [\#](https://github.com/cosmos/relayer/pull/) Ignore only file not exist error when loadConfigFile. +* [\#1325](https://github.com/cosmos/relayer/pull/1325) Ignore only file not exist error when loadConfigFile. ## v0.9.3 From b3b369bc8445dc4ac812e90c63d3475e34f759ab Mon Sep 17 00:00:00 2001 From: mmsqe Date: Fri, 10 Nov 2023 09:12:09 +0800 Subject: [PATCH 3/3] Apply suggestions from code review --- cmd/appstate.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmd/appstate.go b/cmd/appstate.go index 96e2969d5..887be2cca 100644 --- a/cmd/appstate.go +++ b/cmd/appstate.go @@ -6,6 +6,7 @@ import ( "errors" "fmt" "io" + "io/fs" "os" "path" @@ -40,7 +41,7 @@ func (a *appState) loadConfigFile(ctx context.Context) error { if _, err := os.Stat(cfgPath); err != nil { // don't return error if file doesn't exist - if os.IsExist(err) { + if errors.Is(err, fs.ErrNotExist) { err = nil } return err