Skip to content
This repository was archived by the owner on Sep 9, 2024. It is now read-only.

Commit 6eff162

Browse files
committed
fix: nested collection and folder support conflict
1 parent 5a51c55 commit 6eff162

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/middlewares/joi/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export function defaultSchema({ path = requiredString } = {}) {
2929

3030
const asset = Joi.object({
3131
path,
32-
content: requiredString,
32+
content: Joi.string().allow(''),
3333
encoding: requiredString.valid('base64'),
3434
});
3535

src/middlewares/utils/fs.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,15 @@ async function listFiles(dir: string, extension: string, depth: number): Promise
1313
const files = await Promise.all(
1414
dirents.map(dirent => {
1515
const res = path.join(dir, dirent.name);
16+
const isDirectory = dirent.isDirectory();
17+
18+
if (depth > 1 && isDirectory) {
19+
return listFiles(res, extension, depth - 1);
20+
}
21+
1622
return {
17-
file: [res].filter(f => f.endsWith(extension))[0],
18-
isDirectory: dirent.isDirectory(),
23+
file: extension === '' ? res : [res].filter(f => f.endsWith(extension))[0],
24+
isDirectory,
1925
} as FsItem;
2026
}),
2127
);

0 commit comments

Comments
 (0)