Skip to content

Commit b52e7bf

Browse files
committed
Correctly detect empty folder
1 parent fa13784 commit b52e7bf

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "browser-fs-access",
3-
"version": "0.32.0",
3+
"version": "0.32.1",
44
"description": "File System Access API with legacy fallback in the browser.",
55
"type": "module",
66
"source": "./src/index.js",

src/fs-access/directory-open.mjs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,10 @@ export default async (options = {}) => {
6060
startIn: options.startIn,
6161
mode: options.mode,
6262
});
63-
const files = getFiles(
64-
handle,
65-
options.recursive,
66-
undefined,
67-
options.skipDirectory
68-
);
69-
return handle.values ? files : [handle];
63+
// If the directory is empty, return an array with the handle.
64+
if ((await (await handle.values()).next()).done) {
65+
return [handle];
66+
}
67+
// Else, return an array of File objects.
68+
return getFiles(handle, options.recursive, undefined, options.skipDirectory);
7069
};

0 commit comments

Comments
 (0)