forked from TrueCloudLab/rclone
fs: fix the defaults overriding the actual config
After re-organising the config it became apparent that there was a bug in the config system which hadn't manifested until now. This was the default config overriding the main config and was fixed by noting when the defaults had actually changed.
This commit is contained in:
parent
8fbb259091
commit
91558ce6aa
2 changed files with 13 additions and 1 deletions
|
@ -64,7 +64,7 @@ type regInfoValues struct {
|
|||
// the default values
|
||||
func (r *regInfoValues) Get(key string) (value string, ok bool) {
|
||||
opt := r.options.Get(key)
|
||||
if opt != nil && (r.useDefault || opt.Value != nil) {
|
||||
if opt != nil && (r.useDefault || !opt.IsDefault()) {
|
||||
return opt.String(), true
|
||||
}
|
||||
return "", false
|
||||
|
|
|
@ -244,6 +244,18 @@ func (o *Option) GetValue() interface{} {
|
|||
return val
|
||||
}
|
||||
|
||||
// IsDefault returns true if the value is the default value
|
||||
func (o *Option) IsDefault() bool {
|
||||
if o.Value == nil {
|
||||
return true
|
||||
}
|
||||
Default := o.Default
|
||||
if Default == nil {
|
||||
Default = ""
|
||||
}
|
||||
return reflect.DeepEqual(o.Value, Default)
|
||||
}
|
||||
|
||||
// String turns Option into a string
|
||||
func (o *Option) String() string {
|
||||
v := o.GetValue()
|
||||
|
|
Loading…
Reference in a new issue