Skip to content

Commit

Permalink
Fix bug in UpdateConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
thrasher- committed May 9, 2018
1 parent d882c1d commit 981b600
Showing 1 changed file with 23 additions and 23 deletions.
46 changes: 23 additions & 23 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -512,14 +512,9 @@ func (c *Config) SaveConfig(configPath string) error {
return nil
}

// LoadConfig loads your configuration file into your configuration object
func (c *Config) LoadConfig(configPath string) error {
err := c.ReadConfig(configPath)
if err != nil {
return fmt.Errorf(ErrFailureOpeningConfig, configPath, err)
}

err = c.CheckExchangeConfigValues()
// CheckConfig checks all config settings
func (c *Config) CheckConfig() error {
err := c.CheckExchangeConfigValues()
if err != nil {
return fmt.Errorf(ErrCheckingConfigValues, err)
}
Expand Down Expand Up @@ -568,29 +563,34 @@ func (c *Config) LoadConfig(configPath string) error {
return nil
}

// UpdateConfig updates the config with a supplied config file
func (c *Config) UpdateConfig(configPath string, newCfg Config) error {
if c.Name != newCfg.Name && newCfg.Name != "" {
c.Name = newCfg.Name
}

err := newCfg.CheckExchangeConfigValues()
// LoadConfig loads your configuration file into your configuration object
func (c *Config) LoadConfig(configPath string) error {
err := c.ReadConfig(configPath)
if err != nil {
return err
}
c.Exchanges = newCfg.Exchanges

if c.CurrencyPairFormat != newCfg.CurrencyPairFormat {
c.CurrencyPairFormat = newCfg.CurrencyPairFormat
return fmt.Errorf(ErrFailureOpeningConfig, configPath, err)
}

c.Portfolio = newCfg.Portfolio
return c.CheckConfig()
}

err = newCfg.CheckSMSGlobalConfigValues()
// UpdateConfig updates the config with a supplied config file
func (c *Config) UpdateConfig(configPath string, newCfg Config) error {
err := newCfg.CheckConfig()
if err != nil {
return err
}

c.Name = newCfg.Name
c.EncryptConfig = newCfg.EncryptConfig
c.Cryptocurrencies = newCfg.Cryptocurrencies
c.CurrencyExchangeProvider = newCfg.CurrencyExchangeProvider
c.CurrencyPairFormat = newCfg.CurrencyPairFormat
c.FiatDisplayCurrency = newCfg.FiatDisplayCurrency
c.GlobalHTTPTimeout = newCfg.GlobalHTTPTimeout
c.Portfolio = newCfg.Portfolio
c.SMS = newCfg.SMS
c.Webserver = newCfg.Webserver
c.Exchanges = newCfg.Exchanges

err = c.SaveConfig(configPath)
if err != nil {
Expand Down

0 comments on commit 981b600

Please sign in to comment.