fix(migration): handle already-v5 settings and ensure 'failed' branch writes v5 marker

This commit is contained in:
2026-06-08 07:02:45 +05:30
parent 74dde8d6d1
commit aeadde5f40
4 changed files with 37 additions and 1 deletions
+4
View File
@@ -25,6 +25,10 @@ class MigrationRunner {
return 'migrated';
} catch (err) {
console.error('[migration-runner] transform failed:', err.message);
// Back up the original and write v5 marker so future launches skip migration.
// Without this, every launch would fail again and the user stays on defaults.
fs.copyFileSync(this.file, this.backup);
fs.writeFileSync(this.file, JSON.stringify({ ...raw, 'migration.version': 5 }, null, 2));
return 'failed';
}
}