Fix crash

ReferenceError: Cannot access 'backups' before initialization
This commit is contained in:
Girish Ramakrishnan
2022-04-08 16:27:11 -07:00
parent 21b900258a
commit 87cb90c9b6

View File

@@ -2477,11 +2477,11 @@ async function restoreInstalledApps(options, auditSource) {
apps = apps.filter(app => app.installationState !== exports.ISTATE_PENDING_RESTORE); // safeguard against tasks being created non-stop if we crash on startup
for (const app of apps) {
const [error, backups] = await safe(backups.getByIdentifierAndStatePaged(app.id, backups.BACKUP_STATE_NORMAL, 1, 1));
const [error, result] = await safe(backups.getByIdentifierAndStatePaged(app.id, backups.BACKUP_STATE_NORMAL, 1, 1));
let installationState, restoreConfig, oldManifest;
if (!error && backups.length) {
if (!error && result.length) {
installationState = exports.ISTATE_PENDING_RESTORE;
restoreConfig = { remotePath: backups[0].remotePath, backupFormat: backups[0].format };
restoreConfig = { remotePath: result[0].remotePath, backupFormat: result[0].format };
oldManifest = app.manifest;
} else {
installationState = exports.ISTATE_PENDING_INSTALL;