backup: fix listDir to return path instead of fullPath
This commit is contained in:
@@ -194,7 +194,7 @@ async function downloadDir(backupTarget, backupFilePath, dataLayout, progressCal
|
||||
debug(`downloadDir: ${backupFilePath} to ${dataLayout.toString()}. encryption filenames: ${encryptedFilenames} content: ${!!backupTarget.encryption}`);
|
||||
|
||||
async function downloadFile(entry) {
|
||||
let relativePath = path.relative(backupFilePath, entry.fullPath);
|
||||
let relativePath = path.relative(backupFilePath, entry.path);
|
||||
if (encryptedFilenames) {
|
||||
const { error, result } = hush.decryptFilePath(relativePath, backupTarget.encryption);
|
||||
if (error) throw new BoxError(BoxError.CRYPTO_ERROR, 'Unable to decrypt file');
|
||||
@@ -206,17 +206,17 @@ async function downloadDir(backupTarget, backupFilePath, dataLayout, progressCal
|
||||
if (mkdirError) throw new BoxError(BoxError.FS_ERROR, mkdirError.message);
|
||||
|
||||
await promiseRetry({ times: 3, interval: 20000 }, async function () {
|
||||
const [downloadError, sourceStream] = await safe(backupTargets.storageApi(backupTarget).download(backupTarget.config, entry.fullPath));
|
||||
const [downloadError, sourceStream] = await safe(backupTargets.storageApi(backupTarget).download(backupTarget.config, entry.path));
|
||||
if (downloadError) {
|
||||
progressCallback({ message: `Download ${entry.fullPath} to ${destFilePath} errored: ${downloadError.message}` });
|
||||
progressCallback({ message: `Download ${entry.path} to ${destFilePath} errored: ${downloadError.message}` });
|
||||
throw downloadError;
|
||||
}
|
||||
|
||||
const ps = new ProgressStream({ interval: 10000 }); // display a progress every 10 seconds
|
||||
ps.on('progress', function (progress) {
|
||||
const transferred = Math.round(progress.transferred/1024/1024), speed = Math.round(progress.speed/1024/1024);
|
||||
if (!transferred && !speed) return progressCallback({ message: `Downloading ${entry.fullPath}` }); // 0M@0MBps looks wrong
|
||||
progressCallback({ message: `Downloading ${entry.fullPath}: ${transferred}M@${speed}MBps` });
|
||||
if (!transferred && !speed) return progressCallback({ message: `Downloading ${entry.path}` }); // 0M@0MBps looks wrong
|
||||
progressCallback({ message: `Downloading ${entry.path}: ${transferred}M@${speed}MBps` });
|
||||
});
|
||||
|
||||
const destStream = fs.createWriteStream(destFilePath);
|
||||
@@ -230,14 +230,14 @@ async function downloadDir(backupTarget, backupFilePath, dataLayout, progressCal
|
||||
|
||||
streams.push(destStream);
|
||||
|
||||
progressCallback({ message: `Downloading ${entry.fullPath} to ${destFilePath}` });
|
||||
progressCallback({ message: `Downloading ${entry.path} to ${destFilePath}` });
|
||||
|
||||
const [pipelineError] = await safe(stream.pipeline(streams));
|
||||
if (pipelineError) {
|
||||
progressCallback({ message: `Download error ${entry.fullPath} to ${destFilePath}: ${pipelineError.message}` });
|
||||
progressCallback({ message: `Download error ${entry.path} to ${destFilePath}: ${pipelineError.message}` });
|
||||
throw pipelineError;
|
||||
}
|
||||
progressCallback({ message: `Download finished ${entry.fullPath} to ${destFilePath}` });
|
||||
progressCallback({ message: `Download finished ${entry.path} to ${destFilePath}` });
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user