fix(desktop): adopt the bundled core when there is no workspace to back up

cp() rejects with ENOENT when the workspace folder does not exist, which made every start fail before the installed core could run. Skip the backup in that case; rollback already skips a missing backup.
This commit is contained in:
Gaurav Dubey
2026-11-12 12:24:17 +00:00
parent 8a7ec68a45
commit ff43aec3a0
+7 -2
View File
@@ -257,9 +257,14 @@ async function boot() {
// The app was installed over an older core: switch to the bundled one with the
// same backup and rollback as a manual update.
status({ phase: 'starting', step: 'updating' });
const backup = path.join(userRoot, 'backups', `before-${active.manifest.runtimeId}-${Date.now()}`);
let backup = path.join(userRoot, 'backups', `before-${active.manifest.runtimeId}-${Date.now()}`);
await mkdir(path.dirname(backup), { recursive: true });
await cp(runtimeHome, backup, { recursive: true });
try { await cp(runtimeHome, backup, { recursive: true }); }
catch (error) {
// No workspace yet means nothing to restore on rollback.
if (error.code !== 'ENOENT') throw error;
backup = undefined;
}
transaction = { phase: 'testing', previous, candidate: active.manifest, backup };
await writeJSON(transactionFile, transaction);
}