Remove redundant identity key updates
We were re-saving the key when it did not conflict with the exisiting value.
This commit is contained in:
parent
2e272b6894
commit
c94c4bc7e0
1 changed files with 11 additions and 3 deletions
|
@ -263,9 +263,17 @@
|
||||||
var identityKey = new IdentityKey({id: number});
|
var identityKey = new IdentityKey({id: number});
|
||||||
identityKey.fetch().always(function() {
|
identityKey.fetch().always(function() {
|
||||||
var oldpublicKey = identityKey.get('publicKey');
|
var oldpublicKey = identityKey.get('publicKey');
|
||||||
if (oldpublicKey && !equalArrayBuffers(oldpublicKey, publicKey))
|
if (!oldpublicKey) {
|
||||||
throw new Error("Attempted to overwrite a different identity key");
|
// Lookup failed, or the current key was removed, so save this one.
|
||||||
identityKey.save({publicKey: publicKey}).then(resolve);
|
identityKey.save({publicKey: publicKey}).then(resolve);
|
||||||
|
} else {
|
||||||
|
// Key exists, if it matches do nothing, else throw
|
||||||
|
if (equalArrayBuffers(oldpublicKey, publicKey)) {
|
||||||
|
resolve();
|
||||||
|
} else {
|
||||||
|
throw new Error("Attempted to overwrite a different identity key");
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue