storage: make listDir return paths relative to the root
this seems more natural to work with
This commit is contained in:
@@ -154,7 +154,8 @@ async function listDir(config, remotePath, batchSize, marker) {
|
||||
assert.strictEqual(typeof batchSize, 'number');
|
||||
assert(typeof marker !== 'undefined');
|
||||
|
||||
const fullRemotePath = path.join(getRootPath(config), remotePath);
|
||||
const rootPath = getRootPath(config);
|
||||
const fullRemotePath = path.join(rootPath, remotePath);
|
||||
const stack = marker ? marker.stack : [fullRemotePath];
|
||||
const fileStream = marker ? marker.fileStream : [];
|
||||
if (!marker) marker = { stack, fileStream };
|
||||
@@ -170,7 +171,7 @@ async function listDir(config, remotePath, batchSize, marker) {
|
||||
stack.push(fullEntryPath);
|
||||
} else if (dirent.isFile()) { // does not include symlink
|
||||
const stat = await fs.promises.lstat(fullEntryPath);
|
||||
fileStream.push({ path: path.relative(fullRemotePath, fullEntryPath), size: stat.size });
|
||||
fileStream.push({ path: path.relative(rootPath, fullEntryPath), size: stat.size });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user