backups: recursively update the dep preserveSecs

One idea was to compute this at cleanup time, but this has two problems:

* the UI won't reflect this value. can be good or bad
* the cleaner has no easy way to find out the "parent". I guess we should
  change our data structure, if we want to go down this route...
This commit is contained in:
Girish Ramakrishnan
2022-04-04 21:23:59 -07:00
parent 452a4d9a75
commit ea3fd27123
3 changed files with 46 additions and 16 deletions

View File

@@ -797,13 +797,14 @@ async function rotateBoxBackup(backupConfig, tag, options, dependsOn, progressCa
identifier: backups.BACKUP_IDENTIFIER_BOX,
dependsOn,
manifest: null,
format
format,
preserveSecs: options.preserveSecs || 0
};
const id = await backups.add(data);
const [copyBackupError] = await safe(copy(backupConfig, 'snapshot/box', remotePath, progressCallback));
const state = copyBackupError ? backups.BACKUP_STATE_ERROR : backups.BACKUP_STATE_NORMAL;
await backups.update(id, { preserveSecs: options.preserveSecs || 0, state });
await backups.setState(id, state);
if (copyBackupError) throw copyBackupError;
return id;
@@ -843,15 +844,16 @@ async function rotateAppBackup(backupConfig, app, tag, options, progressCallback
type: backups.BACKUP_TYPE_APP,
state: backups.BACKUP_STATE_CREATING,
identifier: app.id,
dependsOn: [ ],
dependsOn: [],
manifest,
format: format
format,
preserveSecs: options.preserveSecs || 0
};
const id = await backups.add(data);
const copyBackupError = await safe(copy(backupConfig, `snapshot/app_${app.id}`, remotePath, progressCallback));
const state = copyBackupError ? backups.BACKUP_STATE_ERROR : backups.BACKUP_STATE_NORMAL;
await backups.update(id, { preserveSecs: options.preserveSecs || 0, state });
await backups.setState(id, state);
if (copyBackupError) throw copyBackupError;
return id;
@@ -979,13 +981,14 @@ async function rotateMailBackup(backupConfig, tag, options, progressCallback) {
identifier: backups.BACKUP_IDENTIFIER_MAIL,
dependsOn: [],
manifest: null,
format: format
format,
preserveSecs: options.preserveSecs || 0
};
const id = await backups.add(data);
const [copyBackupError] = await safe(copy(backupConfig, 'snapshot/mail', remotePath, progressCallback));
const state = copyBackupError ? backups.BACKUP_STATE_ERROR : backups.BACKUP_STATE_NORMAL;
await backups.update(id, { preserveSecs: options.preserveSecs || 0, state });
await backups.setState(id, state);
if (copyBackupError) throw copyBackupError;
return id;