storage: make listDir return paths relative to the root

this seems more natural to work with
This commit is contained in:
Girish Ramakrishnan
2025-08-16 07:43:43 +05:30
parent 19682ec21b
commit 832a25601d
5 changed files with 13 additions and 12 deletions

View File

@@ -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 });
}
}