@@ -6,7 +6,7 @@ import { pipe } from 'it-pipe'
66import { CustomProgressEvent } from 'progress-events'
77import { NotUnixFSError } from '../../../errors.js'
88import { isBasicExporterOptions } from '../../../utils/is-basic-exporter-options.ts'
9- import type { ExporterOptions , Resolve , UnixfsV1DirectoryContent , UnixfsV1Resolver , ReadableStorage , ExportWalk , BasicExporterOptions , UnixfsV1BasicContent } from '../../../index.js'
9+ import type { ExporterOptions , Resolve , UnixfsV1DirectoryContent , UnixfsV1Resolver , ReadableStorage , ExportWalk , BasicExporterOptions } from '../../../index.js'
1010import type { PBNode } from '@ipld/dag-pb'
1111
1212const hamtShardedDirectoryContent : UnixfsV1Resolver = ( cid , node , unixfs , path , resolve , depth , blockstore ) => {
@@ -49,24 +49,27 @@ async function * listDirectory (node: PBNode, path: string, resolve: Resolve, de
4949
5050 if ( name != null && name !== '' ) {
5151 const linkPath = `${ path } /${ name } `
52+ const load = async ( options = { } ) => {
53+ const result = await resolve ( link . Hash , name , linkPath , [ ] , depth + 1 , blockstore , options )
54+ return result . entry
55+ }
5256
5357 if ( isBasicExporterOptions ( options ) ) {
54- const basic : UnixfsV1BasicContent = {
55- cid : link . Hash ,
56- name,
57- path : linkPath ,
58- resolve : async ( options = { } ) => {
59- const result = await resolve ( link . Hash , name , linkPath , [ ] , depth + 1 , blockstore , options )
60- return result . entry
61- }
58+ return {
59+ entries : [ {
60+ cid : link . Hash ,
61+ name,
62+ path : linkPath ,
63+ resolve : load
64+ } ]
6265 }
63-
64- return { entries : [ basic ] }
6566 }
6667
67- const result = await resolve ( link . Hash , name , linkPath , [ ] , depth + 1 , blockstore , options )
68-
69- return { entries : result . entry == null ? [ ] : [ result . entry ] }
68+ return {
69+ entries : [
70+ await load ( )
71+ ] . filter ( Boolean )
72+ }
7073 } else {
7174 // descend into subshard
7275 const block = await blockstore . get ( link . Hash , options )
@@ -76,7 +79,9 @@ async function * listDirectory (node: PBNode, path: string, resolve: Resolve, de
7679 cid : link . Hash
7780 } ) )
7881
79- return { entries : listDirectory ( node , path , resolve , depth , blockstore , options ) }
82+ return {
83+ entries : listDirectory ( node , path , resolve , depth , blockstore , options )
84+ }
8085 }
8186 }
8287 } ) ,
0 commit comments