@@ -54,7 +54,7 @@ export class WebAccessFS extends Async(IndexFS) {
5454 * Loads all of the handles.
5555 *@internal @hidden
5656 */
57- async _loadHandles ( path :string , handle :FileSystemDirectoryHandle ) {
57+ protected async _loadHandles ( path :string , handle :FileSystemDirectoryHandle ) {
5858for await ( const [ key , child ] of handle . entries ( ) ) {
5959const p = join ( path , key ) ;
6060this . _handles . set ( p , child ) ;
@@ -67,6 +67,9 @@ export class WebAccessFS extends Async(IndexFS) {
6767 *@internal @hidden
6868 */
6969async _loadMetadata ( metadataPath ?:string ) :Promise < void > {
70+ this . _handles . set ( '/' , this . root ) ;
71+ await this . _loadHandles ( '/' , this . root ) ;
72+
7073if ( metadataPath ) {
7174const handle = await this . get ( 'file' , metadataPath ) ;
7275const file = await handle . getFile ( ) ;
@@ -100,8 +103,7 @@ export class WebAccessFS extends Async(IndexFS) {
100103) {
101104super ( 0x77656261 , 'webaccessfs' ) ;
102105this . attributes . set ( 'no_buffer_resize' , true ) ;
103- if ( ! disableHandleCache ) this . _handles . set ( '/' , root ) ;
104- else this . attributes . set ( 'no_handle_cache' , true ) ;
106+ if ( disableHandleCache ) this . attributes . set ( 'no_handle_cache' , true ) ;
105107}
106108
107109protected async remove ( path :string ) :Promise < void > {
@@ -200,7 +202,7 @@ export class WebAccessFS extends Async(IndexFS) {
200202
201203if ( ! this . disableHandleCache ) {
202204const handle = this . _handles . get ( path ) ;
203- if ( ! handle ) throw withErrno ( 'ENODATA ' ) ;
205+ if ( ! handle ) throw withErrno ( 'ENOENT ' ) ;
204206
205207if ( kind && ! isKind ( handle , kind ) ) throw withErrno ( kind == 'directory' ?'ENOTDIR' :'EISDIR' ) ;
206208
@@ -235,9 +237,7 @@ const _WebAccess = {
235237} ,
236238
237239async create ( options :WebAccessOptions ) {
238- const fs = new WebAccessFS ( options . handle , options . disableHandleCache ) ;
239- if ( options . disableHandleCache ) return fs ;
240- await fs . _loadHandles ( '/' , options . handle ) ;
240+ const fs = new WebAccessFS ( options . handle ) ;
241241await fs . _loadMetadata ( options . metadata ) ;
242242return fs ;
243243} ,