fix(config): deep copy configuration defaults (fixes #9916) (#10101)

### Purpose

Setting default configuration was not working properly since the
defaults struct is not deeply copied.

### Testing

Try running commands to change default configuration and either inspect
`config.xml` or `/rest/config` result to see the applied changed.
Example:
```
./syncthing cli config defaults folder versioning params set keep 5
```
This commit is contained in:
Hazem Krimi
2025-05-09 06:40:32 +01:00
committed by GitHub
parent b038650810
commit 702ed8ecc1

View File

@@ -235,6 +235,10 @@ func ReadJSON(r io.Reader, myID protocol.DeviceID) (Configuration, error) {
func (cfg Configuration) Copy() Configuration {
newCfg := cfg
// Deep copy Defaults
newCfg.Defaults.Folder = cfg.Defaults.Folder.Copy()
newCfg.Defaults.Device = cfg.Defaults.Device.Copy()
// Deep copy FolderConfigurations
newCfg.Folders = make([]FolderConfiguration, len(cfg.Folders))
for i := range newCfg.Folders {