no need for format specific getBackupFilePath
This commit is contained in:
@@ -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()}`);
|
||||
|
||||
|
||||
@@ -16,16 +16,6 @@ const assert = require('assert'),
|
||||
tar = require('tar-stream'),
|
||||
zlib = require('zlib');
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
// In tar, the entry header contains the file size. If we don't provide it those many bytes, the tar will become corrupt
|
||||
// Linux provides no guarantee of how many bytes can be read from a file. This is the case with sqlite and log files
|
||||
// which are accessed by other processes when tar is in action. This class handles overflow and underflow
|
||||
@@ -236,7 +226,7 @@ async function download(backupTarget, remotePath, dataLayout, progressCallback)
|
||||
|
||||
debug(`download: Downloading ${remotePath} to ${dataLayout.toString()}`);
|
||||
|
||||
const backupFilePath = getBackupFilePath(backupTarget, remotePath);
|
||||
const backupFilePath = backupTargets.getBackupFilePath(backupTarget, remotePath);
|
||||
|
||||
await promiseRetry({ times: 5, interval: 20000, debug }, async () => {
|
||||
progressCallback({ message: `Downloading backup ${backupFilePath}` });
|
||||
@@ -254,7 +244,7 @@ async function upload(backupTarget, remotePath, dataLayout, progressCallback) {
|
||||
|
||||
debug(`upload: Uploading ${dataLayout.toString()} to ${remotePath}`);
|
||||
|
||||
const backupFilePath = getBackupFilePath(backupTarget, remotePath);
|
||||
const backupFilePath = backupTargets.getBackupFilePath(backupTarget, remotePath);
|
||||
|
||||
await promiseRetry({ times: 5, interval: 20000, debug }, async () => {
|
||||
progressCallback({ message: `Uploading backup ${backupFilePath}` });
|
||||
@@ -265,7 +255,6 @@ async function upload(backupTarget, remotePath, dataLayout, progressCallback) {
|
||||
}
|
||||
|
||||
exports = module.exports = {
|
||||
getBackupFilePath,
|
||||
download,
|
||||
upload,
|
||||
|
||||
|
||||
Reference in New Issue
Block a user