storage: make listDir return paths relative to the root
this seems more natural to work with
This commit is contained in:
@@ -359,7 +359,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 { path: path.relative(fullRemotePath, c.Key), size: c.Size }; });
|
||||
const entries = listData.Contents.map(function (c) { return { path: path.relative(apiConfig.prefix, c.Key), size: c.Size }; });
|
||||
return { entries, marker: !listData.IsTruncated ? null : listData.NextContinuationToken };
|
||||
}
|
||||
|
||||
@@ -487,8 +487,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.path);
|
||||
const fullToPath = path.join(apiConfig.prefix, toPath, entry.path);
|
||||
const fullFromPath = path.join(apiConfig.prefix, entry.path);
|
||||
const fullToPath = path.join(apiConfig.prefix, toPath, path.relative(fromPath, entry.path));
|
||||
await copyFile(apiConfig, fullFromPath, fullToPath, entry.size, progressCallback);
|
||||
});
|
||||
if (!batch.marker) break;
|
||||
|
||||
Reference in New Issue
Block a user