@@ -6,7 +6,7 @@ import { pipe } from 'it-pipe'
6
6
import { CustomProgressEvent } from 'progress-events'
7
7
import { NotUnixFSError } from '../../../errors.js'
8
8
import { 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'
10
10
import type { PBNode } from '@ipld/dag-pb'
11
11
12
12
const hamtShardedDirectoryContent : UnixfsV1Resolver = ( cid , node , unixfs , path , resolve , depth , blockstore ) => {
@@ -49,24 +49,27 @@ async function * listDirectory (node: PBNode, path: string, resolve: Resolve, de
49
49
50
50
if ( name != null && name !== '' ) {
51
51
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
+ }
52
56
53
57
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
+ } ]
62
65
}
63
-
64
- return { entries : [ basic ] }
65
66
}
66
67
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
+ }
70
73
} else {
71
74
// descend into subshard
72
75
const block = await blockstore . get ( link . Hash , options )
@@ -76,7 +79,9 @@ async function * listDirectory (node: PBNode, path: string, resolve: Resolve, de
76
79
cid : link . Hash
77
80
} ) )
78
81
79
- return { entries : listDirectory ( node , path , resolve , depth , blockstore , options ) }
82
+ return {
83
+ entries : listDirectory ( node , path , resolve , depth , blockstore , options )
84
+ }
80
85
}
81
86
}
82
87
} ) ,
0 commit comments