backup: fix listDir to return path instead of fullPath
This commit is contained in:
@@ -341,7 +341,7 @@ async function listDir(apiConfig, remotePath, batchSize, marker) {
|
||||
const [error, listData] = await safe(s3.listObjectsV2(listParams));
|
||||
if (error) throw new BoxError(BoxError.EXTERNAL_ERROR, `Error listing objects in ${fullRemotePath}. ${formatError(error)}`);
|
||||
if (listData.KeyCount === 0 || listData.Contents.length === 0) return { entries: [], marker: null }; // no more
|
||||
const entries = listData.Contents.map(function (c) { return { fullPath: path.relative(fullRemotePath, c.Key), size: c.Size }; });
|
||||
const entries = listData.Contents.map(function (c) { return { path: path.relative(fullRemotePath, c.Key), size: c.Size }; });
|
||||
return { entries, marker: !listData.IsTruncated ? null : listData.NextContinuationToken };
|
||||
}
|
||||
|
||||
@@ -469,8 +469,8 @@ async function copy(apiConfig, fromPath, toPath, progressCallback) {
|
||||
total += batch.entries.length;
|
||||
progressCallback({ message: `Copying files from ${total-batch.entries.length}-${total}` });
|
||||
await async.eachLimit(batch.entries, concurrency, async (entry) => {
|
||||
const fullFromPath = path.join(apiConfig.prefix, fromPath, entry.fullPath);
|
||||
const fullToPath = path.join(apiConfig.prefix, toPath, entry.fullPath);
|
||||
const fullFromPath = path.join(apiConfig.prefix, fromPath, entry.path);
|
||||
const fullToPath = path.join(apiConfig.prefix, toPath, entry.path);
|
||||
await copyFile(apiConfig, fullFromPath, fullToPath, entry.size, progressCallback);
|
||||
});
|
||||
if (!batch.marker) break;
|
||||
@@ -537,11 +537,11 @@ async function removeDir(apiConfig, remotePathPrefix, progressCallback) {
|
||||
const deleteParams = {
|
||||
Bucket: apiConfig.bucket,
|
||||
Delete: {
|
||||
Objects: objects.map(function (o) { return { Key: path.join(apiConfig.prefix, o.fullPath) }; })
|
||||
Objects: objects.map(function (o) { return { Key: path.join(apiConfig.prefix, o.path) }; })
|
||||
}
|
||||
};
|
||||
|
||||
const fullFirstPath = path.join(apiConfig.prefix, objects[0].fullPath), fullLastPath = path.join(apiConfig.prefix, objects[objects.length-1].fullPath);
|
||||
const fullFirstPath = path.join(apiConfig.prefix, objects[0].path), fullLastPath = path.join(apiConfig.prefix, objects[objects.length-1].path);
|
||||
progressCallback({ message: `Removing ${objects.length} files from ${fullFirstPath} to ${fullLastPath}` });
|
||||
|
||||
// deleteObjects does not return error if key is not found
|
||||
|
||||
Reference in New Issue
Block a user