rename backupTargets to backupSites

This commit is contained in:
Girish Ramakrishnan
2025-09-12 09:48:37 +02:00
parent f8015c156e
commit c5b7264f1a
38 changed files with 751 additions and 751 deletions
+20 -20
View File
@@ -1,7 +1,7 @@
'use strict';
const assert = require('node:assert'),
backupTargets = require('../backuptargets.js'),
backupSites = require('../backupsites.js'),
BoxError = require('../boxerror.js'),
DataLayout = require('../datalayout.js'),
debug = require('debug')('box:backupformat/tgz'),
@@ -116,9 +116,9 @@ async function addPathToPack(pack, localPath, dataLayout) {
await addEntryToPack(pack, header, { /* options */ });
++stats.dirCount;
} else if (entry.isSymbolicLink()) {
const [readlinkError, target] = await safe(fs.promises.readlink(abspath));
if (!target) { debug(`tarPack: skipping link, could not readlink ${abspath}: ${readlinkError.message}`); continue; }
const header = { name: headerName, type: 'symlink', linkname: target, uid: process.getuid(), gid: process.getgid() };
const [readlinkError, site] = await safe(fs.promises.readlink(abspath));
if (!site) { debug(`tarPack: skipping link, could not readlink ${abspath}: ${readlinkError.message}`); continue; }
const header = { name: headerName, type: 'symlink', linkname: site, uid: process.getuid(), gid: process.getgid() };
await addEntryToPack(pack, header, { /* options */ });
++stats.linkCount;
} else {
@@ -235,8 +235,8 @@ async function tarExtract(inStream, dataLayout, encryption, progressCallback) {
debug(`tarExtract: pipeline finished: ${JSON.stringify(ps.stats())}`);
}
async function download(backupTarget, remotePath, dataLayout, progressCallback) {
assert.strictEqual(typeof backupTarget, 'object');
async function download(backupSite, remotePath, dataLayout, progressCallback) {
assert.strictEqual(typeof backupSite, 'object');
assert.strictEqual(typeof remotePath, 'string');
assert(dataLayout instanceof DataLayout, 'dataLayout must be a DataLayout');
assert.strictEqual(typeof progressCallback, 'function');
@@ -246,13 +246,13 @@ async function download(backupTarget, remotePath, dataLayout, progressCallback)
await promiseRetry({ times: 5, interval: 20000, debug }, async () => {
progressCallback({ message: `Downloading backup ${remotePath}` });
const sourceStream = await backupTargets.storageApi(backupTarget).download(backupTarget.config, remotePath);
await tarExtract(sourceStream, dataLayout, backupTarget.encryption, progressCallback);
const sourceStream = await backupSites.storageApi(backupSite).download(backupSite.config, remotePath);
await tarExtract(sourceStream, dataLayout, backupSite.encryption, progressCallback);
});
}
async function upload(backupTarget, remotePath, dataLayout, progressCallback) {
assert.strictEqual(typeof backupTarget, 'object');
async function upload(backupSite, remotePath, dataLayout, progressCallback) {
assert.strictEqual(typeof backupSite, 'object');
assert.strictEqual(typeof remotePath, 'string');
assert.strictEqual(typeof dataLayout, 'object');
assert.strictEqual(typeof progressCallback, 'function');
@@ -262,8 +262,8 @@ async function upload(backupTarget, remotePath, dataLayout, progressCallback) {
return await promiseRetry({ times: 5, interval: 20000, debug }, async () => {
progressCallback({ message: `Uploading backup ${remotePath}` });
const uploader = await backupTargets.storageApi(backupTarget).upload(backupTarget.config, remotePath);
const { stats, integrity } = await tarPack(dataLayout, backupTarget.encryption, uploader, progressCallback);
const uploader = await backupSites.storageApi(backupSite).upload(backupSite.config, remotePath);
const { stats, integrity } = await tarPack(dataLayout, backupSite.encryption, uploader, progressCallback);
// use '.' instead of remote path since the backup can be moved to another path
const integrityMap = new Map([ ['.', integrity] ]);
@@ -271,24 +271,24 @@ async function upload(backupTarget, remotePath, dataLayout, progressCallback) {
});
}
async function copy(backupTarget, fromPath, toPath, progressCallback) {
assert.strictEqual(typeof backupTarget, 'object');
async function copy(backupSite, fromPath, toPath, progressCallback) {
assert.strictEqual(typeof backupSite, 'object');
assert.strictEqual(typeof fromPath, 'string');
assert.strictEqual(typeof toPath, 'string');
assert.strictEqual(typeof progressCallback, 'function');
await backupTargets.storageApi(backupTarget).copy(backupTarget.config, fromPath, toPath, progressCallback);
await backupSites.storageApi(backupSite).copy(backupSite.config, fromPath, toPath, progressCallback);
}
async function verify(backupTarget, remotePath, integrityMap, progressCallback) {
assert.strictEqual(typeof backupTarget, 'object');
async function verify(backupSite, remotePath, integrityMap, progressCallback) {
assert.strictEqual(typeof backupSite, 'object');
assert.strictEqual(typeof remotePath, 'string');
assert(util.types.isMap(integrityMap), 'integrityMap should be a Map');
assert.strictEqual(typeof progressCallback, 'function');
debug(`verify: Verifying ${remotePath}`);
const inStream = await backupTargets.storageApi(backupTarget).download(backupTarget.config, remotePath);
const inStream = await backupSites.storageApi(backupSite).download(backupSite.config, remotePath);
let fileCount = 0;
@@ -316,8 +316,8 @@ async function verify(backupTarget, remotePath, integrityMap, progressCallback)
progressCallback({ message: `Downloading ${transferred}M@${speed}MBps` });
});
if (backupTarget.encryption) {
const decrypt = new DecryptStream(backupTarget.encryption);
if (backupSite.encryption) {
const decrypt = new DecryptStream(backupSite.encryption);
const [error] = await safe(stream.pipeline(inStream, ps, hash, decrypt, gunzip, extract));
if (error) throw new BoxError(BoxError.EXTERNAL_ERROR, `tarExtract pipeline error: ${error.message}`);
} else {