Clean up when new key backup version fails to backup
If creating a new key backup version succeeds but backing up to it fails, delete the version to avoid surprises. In addition, this converts the creation of a new key backup to async / await style. Signed-off-by: J. Ryan Stinnett <jryans@gmail.com>
This commit is contained in:
parent
1c4621c98e
commit
2b14f2af5c
1 changed files with 16 additions and 8 deletions
|
@ -92,25 +92,33 @@ export default React.createClass({
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
_createBackup: function() {
|
_createBackup: async function() {
|
||||||
this.setState({
|
this.setState({
|
||||||
phase: PHASE_BACKINGUP,
|
phase: PHASE_BACKINGUP,
|
||||||
error: null,
|
error: null,
|
||||||
});
|
});
|
||||||
this._createBackupPromise = MatrixClientPeg.get().createKeyBackupVersion(
|
let info;
|
||||||
|
try {
|
||||||
|
info = await MatrixClientPeg.get().createKeyBackupVersion(
|
||||||
this._keyBackupInfo,
|
this._keyBackupInfo,
|
||||||
).then((info) => {
|
);
|
||||||
return MatrixClientPeg.get().backupAllGroupSessions(info.version);
|
await MatrixClientPeg.get().backupAllGroupSessions(info.version);
|
||||||
}).then(() => {
|
|
||||||
this.setState({
|
this.setState({
|
||||||
phase: PHASE_DONE,
|
phase: PHASE_DONE,
|
||||||
});
|
});
|
||||||
}).catch(e => {
|
} catch (e) {
|
||||||
console.log("Error creating key backup", e);
|
console.log("Error creating key backup", e);
|
||||||
|
// TODO: If creating a version succeeds, but backup fails, should we
|
||||||
|
// delete the version, disable backup, or do nothing? If we just
|
||||||
|
// disable without deleting, we'll enable on next app reload since
|
||||||
|
// it is trusted.
|
||||||
|
if (info) {
|
||||||
|
MatrixClientPeg.get().deleteKeyBackupVersion(info.version);
|
||||||
|
}
|
||||||
this.setState({
|
this.setState({
|
||||||
error: e,
|
error: e,
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
_onCancel: function() {
|
_onCancel: function() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue