Skip to content

Commit

Permalink
fix(s3fs): local file system list should be recursive by default (#1822)
Browse files Browse the repository at this point in the history
  • Loading branch information
blacha authored Aug 20, 2021
1 parent 83488af commit 9367e3f
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions packages/linzjs-s3fs/src/abstractions/file.local.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,12 @@ export class FsLocal implements FileSystem {

async *list(filePath: string): AsyncGenerator<string> {
try {
const files = await fs.promises.readdir(filePath);
for (const file of files) yield path.join(filePath, file);
const files = await fs.promises.readdir(filePath, { withFileTypes: true });
for (const file of files) {
const targetPath = path.join(filePath, file.name);
if (file.isDirectory()) yield* this.list(targetPath);
else yield targetPath;
}
} catch (e) {
throw getCompositeError(e, `Failed to list: ${filePath}`);
}
Expand All @@ -32,11 +36,7 @@ export class FsLocal implements FileSystem {
for await (const file of this.list(filePath)) {
const res = await this.head(file);
if (res == null) continue;
if (res.isDirectory) {
yield* this.listDetails(res.path);
} else {
yield res;
}
yield res;
}
}

Expand Down

0 comments on commit 9367e3f

Please sign in to comment.