Fix bug in UpdateConfig
Fixes
@@ -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)
}
@@ -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
+ return fmt.Errorf(ErrFailureOpeningConfig, configPath, err)
}
- c.Exchanges = newCfg.Exchanges
- if c.CurrencyPairFormat != newCfg.CurrencyPairFormat {
- c.CurrencyPairFormat = newCfg.CurrencyPairFormat
+ return c.CheckConfig()
}
- c.Portfolio = newCfg.Portfolio
-
- 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 {
