Unlink on backup interruption

This commit is contained in:
Fedor Indutny 2024-10-29 08:24:41 -07:00 committed by GitHub
parent 7548e2adc2
commit c0050890a9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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);
}