Skip to content

Commit

Permalink
fix(icq-relayer): return immediately on non-os.IsNotExist errors
Browse files Browse the repository at this point in the history
This change avoids the need to try to brute-force creating
an entirely fresh configuration, in the case where an error
that isn't a path non-existence error occurs, for example
in the case of a permission error on the parent directory
or non-matching user/group permissions. Now we check against
the returned error after os.Stat and accordingly return
immediately or continue to create the configuration.

Fixes quicksilver-zone#1524
  • Loading branch information
odeke-em committed Apr 30, 2024
1 parent 7f095c3 commit 0803c0f
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions icq-relayer/cmd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,15 @@ func initConfig(cmd *cobra.Command) error {
cfgPath := path.Join(home, "config.yaml")
_, err = os.Stat(cfgPath)
if err != nil {
err = config.CreateConfig(home)
if err != nil {
if !os.IsNotExist(err) { // Return immediately
return err
}

if err := config.CreateConfig(home); err != nil {
return err
}
}

viper.SetConfigFile(cfgPath)
err = viper.ReadInConfig()
if err != nil {
Expand Down

0 comments on commit 0803c0f

Please sign in to comment.