move retentionSecs inside retentionPolicy

part of #441
This commit is contained in:
Girish Ramakrishnan
2020-05-14 16:19:35 -07:00
parent 573da29a4d
commit 6a9fe1128f
5 changed files with 27 additions and 7 deletions

View File

@@ -1272,7 +1272,7 @@ function cleanupAppBackups(backupConfig, referencedAppBackups, callback) {
async.eachSeries(appBackups, function iterator(appBackup, iteratorDone) {
if (referencedAppBackups.indexOf(appBackup.id) !== -1) return iteratorDone();
if ((now - appBackup.creationTime) < (appBackup.preserveSecs * 1000)) return iteratorDone();
if ((now - appBackup.creationTime) < (backupConfig.retentionSecs * 1000)) return iteratorDone();
if ((now - appBackup.creationTime) < (backupConfig.retentionPolicy.keepWithin * 1000)) return iteratorDone();
debug('cleanupAppBackups: removing %s', appBackup.id);
@@ -1317,7 +1317,7 @@ function cleanupBoxBackups(backupConfig, auditSource, callback) {
async.eachSeries(boxBackups, function iterator(boxBackup, iteratorNext) {
// TODO: errored backups should probably be cleaned up before retention time, but we will
// have to be careful not to remove any backup currently being created
if ((now - boxBackup.creationTime) < (backupConfig.retentionSecs * 1000)) {
if ((now - boxBackup.creationTime) < (backupConfig.retentionPolicy.keepWithin * 1000)) {
referencedAppBackups = referencedAppBackups.concat(boxBackup.dependsOn);
return iteratorNext();
}
@@ -1391,7 +1391,7 @@ function cleanup(auditSource, progressCallback, callback) {
settings.getBackupConfig(function (error, backupConfig) {
if (error) return callback(error);
if (backupConfig.retentionSecs < 0) {
if (backupConfig.retentionPolicy.keepWithin < 0) {
debug('cleanup: keeping all backups');
return callback(null, {});
}