Skip to content

Commit

Permalink
Correctly detect empty folder
Browse files Browse the repository at this point in the history
  • Loading branch information
tomayac committed Feb 20, 2023
1 parent fa13784 commit b52e7bf
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "browser-fs-access",
"version": "0.32.0",
"version": "0.32.1",
"description": "File System Access API with legacy fallback in the browser.",
"type": "module",
"source": "./src/index.js",
Expand Down
13 changes: 6 additions & 7 deletions src/fs-access/directory-open.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,10 @@ export default async (options = {}) => {
startIn: options.startIn,
mode: options.mode,
});
const files = getFiles(
handle,
options.recursive,
undefined,
options.skipDirectory
);
return handle.values ? files : [handle];
// If the directory is empty, return an array with the handle.
if ((await (await handle.values()).next()).done) {
return [handle];
}
// Else, return an array of File objects.
return getFiles(handle, options.recursive, undefined, options.skipDirectory);
};

0 comments on commit b52e7bf

Please sign in to comment.