From 3d759ecee0da64195245bfd24240465c058a040d Mon Sep 17 00:00:00 2001 From: foxriver76 Date: Mon, 21 Oct 2024 10:21:44 +0200 Subject: [PATCH] only validate config.json in backup if not setup custom migration - closes #2945 --- CHANGELOG.md | 4 ++++ packages/cli/src/lib/setup/setupBackup.ts | 13 +++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6cc09e015e..756b407a2b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,10 @@ Placeholder for the next version (at the beginning of the line): ## __WORK IN PROGRESS__ --> + +## __WORK IN PROGRESS__ - Lucy +* (@foxriver76) fixed crash case on database migration + ## 7.0.0 (2024-10-06) - Lucy **Breaking changes** * Backups created with 7.0.x cannot be restored with previous version diff --git a/packages/cli/src/lib/setup/setupBackup.ts b/packages/cli/src/lib/setup/setupBackup.ts index 9508074942..64ab44e869 100644 --- a/packages/cli/src/lib/setup/setupBackup.ts +++ b/packages/cli/src/lib/setup/setupBackup.ts @@ -256,7 +256,7 @@ export class BackupRestore { * @param name - name of the backup * @param noConfig - do not store configs (used by setup custom migration) */ - async createBackup(name: string, noConfig?: boolean): Promise { + async createBackup(name: string, noConfig = false): Promise { if (!name) { const d = new Date(); name = `${d.getFullYear()}_${`0${d.getMonth() + 1}`.slice(-2)}_${`0${d.getDate()}`.slice(-2)}-${`0${d.getHours()}`.slice( @@ -367,7 +367,7 @@ export class BackupRestore { console.log(`host.${hostname} Validating backup ...`); try { - await this._validateBackupAfterCreation(); + await this._validateBackupAfterCreation(noConfig); console.log(`host.${hostname} The backup is valid!`); return await this._packBackup(name); @@ -967,10 +967,15 @@ export class BackupRestore { /** * Validates the backup.json and all json files inside the backup after (in temporary directory), here we only abort if backup.json is corrupted + * + * @param noConfig if the backup does not contain a `config.json` (used by setup custom migration) */ - private async _validateBackupAfterCreation(): Promise { + private async _validateBackupAfterCreation(noConfig = false): Promise { const backupBaseDir = path.join(this.tmpDir, 'backup'); - await fs.readJSON(path.join(backupBaseDir, 'config.json')); + + if (!noConfig) { + await fs.readJSON(path.join(backupBaseDir, 'config.json')); + } if (!(await fs.pathExists(path.join(backupBaseDir, 'objects.jsonl')))) { throw new Error('Backup does not contain valid objects');