all: Refactor preparing configuration (#7127)

This commit is contained in:
Simon Frei
2020-11-20 14:21:54 +01:00
committed by GitHub
parent 641b7aee38
commit 24af89c8e2
19 changed files with 207 additions and 147 deletions
+3 -3
View File
@@ -37,7 +37,7 @@ func TestShortIDCheck(t *testing.T) {
{DeviceID: protocol.DeviceID{8, 16, 24, 32, 40, 48, 56, 0, 0}},
{DeviceID: protocol.DeviceID{8, 16, 24, 32, 40, 48, 56, 1, 1}}, // first 56 bits same, differ in the first 64 bits
},
}, events.NoopLogger)
}, protocol.LocalDeviceID, events.NoopLogger)
defer os.Remove(cfg.ConfigPath())
if err := checkShortIDs(cfg); err != nil {
@@ -49,7 +49,7 @@ func TestShortIDCheck(t *testing.T) {
{DeviceID: protocol.DeviceID{8, 16, 24, 32, 40, 48, 56, 64, 0}},
{DeviceID: protocol.DeviceID{8, 16, 24, 32, 40, 48, 56, 64, 1}}, // first 64 bits same
},
}, events.NoopLogger)
}, protocol.LocalDeviceID, events.NoopLogger)
if err := checkShortIDs(cfg); err == nil {
t.Error("Should have gotten an error")
@@ -76,7 +76,7 @@ func TestStartupFail(t *testing.T) {
{DeviceID: id},
{DeviceID: conflID},
},
}, events.NoopLogger)
}, protocol.LocalDeviceID, events.NoopLogger)
defer os.Remove(cfg.ConfigPath())
db := backend.OpenMemory()
+2 -2
View File
@@ -49,12 +49,12 @@ func DefaultConfig(path string, myID protocol.DeviceID, evLogger events.Logger,
if noDefaultFolder {
l.Infoln("We will skip creation of a default folder on first start")
return config.Wrap(path, newCfg, evLogger), nil
return config.Wrap(path, newCfg, myID, evLogger), nil
}
newCfg.Folders = append(newCfg.Folders, config.NewFolderConfiguration(myID, "default", "Default Folder", fs.FilesystemTypeBasic, locations.Get(locations.DefFolder)))
l.Infoln("Default folder created and/or linked to new config")
return config.Wrap(path, newCfg, evLogger), nil
return config.Wrap(path, newCfg, myID, evLogger), nil
}
// LoadConfigAtStartup loads an existing config. If it doesn't yet exist, it