Skip to content

Commit

Permalink
Re-check key backup status on version mismatch
Browse files Browse the repository at this point in the history
This ensures we will report the updated status when consumer code asks for it.

Fixes part of element-hq/element-web#8048.
  • Loading branch information
jryans committed Jan 8, 2019
1 parent e8022e9 commit 90fef43
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/crypto/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,11 +246,9 @@ Crypto.prototype._checkAndStartKeyBackup = async function() {

/**
* Forces a re-check of the key backup and enables/disables it
* as appropriate
*
* @param {object} backupInfo Backup info from /room_keys/version endpoint
* as appropriate.
*/
Crypto.prototype.checkKeyBackup = async function(backupInfo) {
Crypto.prototype.checkKeyBackup = async function() {
this._checkedForBackup = false;
await this._checkAndStartKeyBackup();
};
Expand Down Expand Up @@ -1021,6 +1019,9 @@ Crypto.prototype._scheduleKeyBackupSend = async function() {
err.data.errcode == 'M_NOT_FOUND' ||
err.data.errcode == 'M_WRONG_ROOM_KEYS_VERSION'
) {
// Re-check key backup status on error, so we can be
// sure to present the current situation when asked.
await this.checkKeyBackup();
// Backup version has changed or this backup version
// has been deleted
this.emit("crypto.keyBackupFailed", err.data.errcode);
Expand Down

0 comments on commit 90fef43

Please sign in to comment.