1
mirror of https://github.com/rclone/rclone synced 2024-12-03 13:14:37 +01:00

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:
Nick Craig-Wood 2024-07-12 12:40:12 +01:00
parent 8fbb259091
commit 91558ce6aa
2 changed files with 13 additions and 1 deletions

View File

@ -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

View File

@ -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()