mirror of
https://github.com/HKUDS/DeepTutor.git
synced 2026-12-02 18:46:34 +08:00
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:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user