no need for format specific getBackupFilePath

This commit is contained in:
Girish Ramakrishnan
2025-08-01 20:49:11 +02:00
parent ff6cbf6628
commit 7192439b2c
6 changed files with 25 additions and 38 deletions

View File

@@ -11,7 +11,6 @@ exports = module.exports = {
const apps = require('./apps.js'),
archives = require('./archives.js'),
assert = require('assert'),
backupFormat = require('./backupformat.js'),
backups = require('./backups.js'),
backupTargets = require('./backuptargets.js'),
constants = require('./constants.js'),
@@ -83,7 +82,7 @@ async function removeBackup(target, backup, progressCallback) {
assert.strictEqual(typeof backup, 'object');
assert.strictEqual(typeof progressCallback, 'function');
const backupFilePath = backupFormat.api(target.format).getBackupFilePath(target, backup.remotePath);
const backupFilePath = backupTargets.getBackupFilePath(target, backup.remotePath);
let removeError;
if (target.format ==='tgz') {
@@ -218,7 +217,7 @@ async function cleanupMissingBackups(target, progressCallback) {
for (const backup of result) {
if (backup.state !== backups.BACKUP_STATE_NORMAL) continue; // note: errored and incomplete backups are cleaned up by the backup retention logic
let backupFilePath = backupFormat.api(target.format).getBackupFilePath(target, backup.remotePath);
let backupFilePath = backupTargets.getBackupFilePath(target, backup.remotePath);
if (target.format === 'rsync') backupFilePath = backupFilePath + '/'; // add trailing slash to indicate directory
const [existsError, exists] = await safe(backupTargets.storageApi(target).exists(target.config, backupFilePath));
@@ -255,9 +254,9 @@ async function removeOldAppSnapshots(backupTarget) {
if (app !== null) continue; // app is still installed
if (snapshotInfo[appId].format ==='tgz') {
await safe(backupTargets.storageApi(backupTarget).remove(backupTarget.config, backupFormat.api(snapshotInfo[appId].format).getBackupFilePath(backupTarget, `snapshot/app_${appId}`)), { debug });
await safe(backupTargets.storageApi(backupTarget).remove(backupTarget.config, backupTargets.getBackupFilePath(backupTarget, `snapshot/app_${appId}`)), { debug });
} else {
await safe(backupTargets.storageApi(backupTarget).removeDir(backupTarget.config, backupFormat.api(snapshotInfo[appId].format).getBackupFilePath(backupTarget, `snapshot/app_${appId}`), progressCallback), { debug });
await safe(backupTargets.storageApi(backupTarget).removeDir(backupTarget.config, backupTargets.getBackupFilePath(backupTarget, `snapshot/app_${appId}`), progressCallback), { debug });
}
await backupTargets.setSnapshotInfo(backupTarget, appId, null /* info */);