Fix check

This commit is contained in:
Neil Alexander 2022-02-22 14:30:56 +00:00
parent b4135c4bae
commit 84f8e675d4
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944
2 changed files with 2 additions and 5 deletions

View file

@ -88,10 +88,7 @@ func (m1 *DeviceMessage) DeviceKeysEqual(m2 *DeviceMessage) (bool, error) {
if len(m1.KeyJSON) == 0 && len(m2.KeyJSON) == 0 {
return true, nil // both are empty
}
if len(m1.KeyJSON) == 0 || len(m2.KeyJSON) == 0 {
return false, nil // only one is empty
}
return bytes.Equal(m1.KeyJSON, m2.KeyJSON), nil
return bytes.Equal(m1.KeyJSON, m2.KeyJSON) && len(m1.KeyJSON) > 0, nil
}
// DeviceKeys represents a set of device keys for a single device

View file

@ -718,8 +718,8 @@ func emitDeviceKeyChanges(producer KeyChangeProducer, existing, new []api.Device
for _, existingKey := range existing {
// Do not treat the absence of keys as equal, or else we will not emit key changes
// when users delete devices which never had a key to begin with as both KeyJSONs are nil.
// if bytes.Equal(existingKey.KeyJSON, newKey.KeyJSON) && len(existingKey.KeyJSON) > 0 {
if equal, err := existingKey.DeviceKeysEqual(&newKey); err != nil {
// One of the keys was not a DeviceKeys or the user ID/device ID did not match.
continue
} else if equal {
exists = true