Don't add empty device to config on init (#8933)
We usually want to ensure that our own device is present. However if the given device ID is the empty ID, we shouldn't do that. This is a legimate (though way too non-obvious) use-case when opening the config without knowing/caring about the device ID.
This commit is contained in:
@@ -268,6 +268,9 @@ func (cfg *Configuration) prepare(myID protocol.DeviceID) error {
|
||||
}
|
||||
|
||||
func (cfg *Configuration) ensureMyDevice(myID protocol.DeviceID) {
|
||||
if myID == protocol.EmptyDeviceID {
|
||||
return
|
||||
}
|
||||
for _, device := range cfg.Devices {
|
||||
if device.DeviceID == myID {
|
||||
return
|
||||
@@ -483,6 +486,9 @@ func (cfg *Configuration) SetFolders(folders []FolderConfiguration) {
|
||||
}
|
||||
|
||||
func ensureDevicePresent(devices []FolderDeviceConfiguration, myID protocol.DeviceID) []FolderDeviceConfiguration {
|
||||
if myID == protocol.EmptyDeviceID {
|
||||
return devices
|
||||
}
|
||||
for _, device := range devices {
|
||||
if device.DeviceID.Equals(myID) {
|
||||
return devices
|
||||
|
||||
Reference in New Issue
Block a user