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

@@ -1,7 +1,6 @@
'use strict';
exports = module.exports = {
getBackupFilePath,
download,
upload,
@@ -28,16 +27,6 @@ const assert = require('assert'),
stream = require('stream/promises'),
syncer = require('../syncer.js');
function getBackupFilePath(backupTarget, remotePath) {
assert.strictEqual(typeof backupTarget, 'object');
assert.strictEqual(typeof remotePath, 'string');
// we don't have a rootPath for noop
if (backupTarget.provider === 'noop') return remotePath;
return path.join(backupTarget.config.rootPath, remotePath);
}
async function addFile(sourceFile, encryption, uploader, progressCallback) {
assert.strictEqual(typeof sourceFile, 'string');
assert.strictEqual(typeof encryption, 'object');
@@ -82,7 +71,7 @@ async function processSyncerChange(change, backupTarget, remotePath, dataLayout,
debug('sync: processing task: %j', change);
// the empty task.path is special to signify the directory
const destPath = change.path && backupTarget.encryption?.encryptedFilenames ? hush.encryptFilePath(change.path, backupTarget.encryption) : change.path;
const backupFilePath = path.join(getBackupFilePath(backupTarget, remotePath), destPath);
const backupFilePath = path.join(backupTargets.getBackupFilePath(backupTarget, remotePath), destPath);
if (change.operation === 'removedir') {
debug(`Removing directory ${backupFilePath}`);
@@ -268,7 +257,7 @@ async function download(backupTarget, remotePath, dataLayout, progressCallback)
assert(dataLayout instanceof DataLayout, 'dataLayout must be a DataLayout');
assert.strictEqual(typeof progressCallback, 'function');
const backupFilePath = getBackupFilePath(backupTarget, remotePath);
const backupFilePath = backupTargets.getBackupFilePath(backupTarget, remotePath);
debug(`download: Downloading ${backupFilePath} to ${dataLayout.toString()}`);