diff --git a/ts/services/backups/index.ts b/ts/services/backups/index.ts index e74dac5244..b5e73ced31 100644 --- a/ts/services/backups/index.ts +++ b/ts/services/backups/index.ts @@ -475,8 +475,14 @@ export class BackupsService { this.downloadController = undefined; - // Too late to cancel now try { + // Too late to cancel now, make sure we are unlinked if the process + // is aborted due to error or restart. + const password = window.storage.get('password'); + strictAssert(password != null, 'Must be registered to import backup'); + + await window.storage.remove('password'); + await this.importFromDisk(downloadPath, { ephemeralKey, onProgress: (currentBytes, totalBytes) => { @@ -487,6 +493,9 @@ export class BackupsService { ); }, }); + + // Restore password on success + await window.storage.put('password', password); } finally { await unlink(downloadPath); }