Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix]: only validate config.json in backup if not setup custom migration #2947

Merged
merged 2 commits into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
-->

## __WORK IN PROGRESS__ - Lucy
* (@foxriver76) fixed crash case on database migration
* (@foxriver76) fixed edge case crash cases if notifications are processed nearly simultaneously

## 7.0.0 (2024-10-06) - Lucy
Expand Down
13 changes: 9 additions & 4 deletions packages/cli/src/lib/setup/setupBackup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string> {
async createBackup(name: string, noConfig = false): Promise<string> {
if (!name) {
const d = new Date();
name = `${d.getFullYear()}_${`0${d.getMonth() + 1}`.slice(-2)}_${`0${d.getDate()}`.slice(-2)}-${`0${d.getHours()}`.slice(
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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<void> {
private async _validateBackupAfterCreation(noConfig = false): Promise<void> {
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');
Expand Down
Loading