@@ -72,7 +72,8 @@ import { type ChunkValidator, defaultChunkValidator } from './dag-builder/valida
72
72
import { balanced , type FileLayout } from './layout/index.js'
73
73
import { defaultTreeBuilder } from './tree-builder.js'
74
74
import type { Chunker } from './chunker/index.js'
75
- import type { ReducerProgressEvents } from './dag-builder/file.js'
75
+ import type { DirBuilder } from './dag-builder/dir.js'
76
+ import type { FileBuilder , ReducerProgressEvents } from './dag-builder/file.js'
76
77
import type { Blockstore } from 'interface-blockstore'
77
78
import type { AwaitIterable } from 'interface-store'
78
79
import type { UnixFS , Mtime } from 'ipfs-unixfs'
@@ -270,6 +271,20 @@ export interface ImporterOptions extends ProgressOptions<ImporterProgressEvents>
270
271
* `Error`
271
272
*/
272
273
chunkValidator ?: ChunkValidator
274
+
275
+ /**
276
+ * This option can be used to override how a directory IPLD node is built.
277
+ *
278
+ * This function takes a `Directory` object and returns a `Promise` that resolves to an `InProgressImportResult`.
279
+ */
280
+ dirBuilder ?: DirBuilder
281
+
282
+ /**
283
+ * This option can be used to override how a file IPLD node is built.
284
+ *
285
+ * This function takes a `File` object and returns a `Promise` that resolves to an `InProgressImportResult`.
286
+ */
287
+ fileBuilder ?: FileBuilder
273
288
}
274
289
275
290
export type ImportCandidateStream = AsyncIterable < FileCandidate | DirectoryCandidate > | Iterable < FileCandidate | DirectoryCandidate >
@@ -319,7 +334,7 @@ export async function * importer (source: ImportCandidateStream, blockstore: Wri
319
334
const fileImportConcurrency = options . fileImportConcurrency ?? 50
320
335
const blockWriteConcurrency = options . blockWriteConcurrency ?? 10
321
336
const reduceSingleLeafToSelf = options . reduceSingleLeafToSelf ?? true
322
-
337
+
323
338
324
339
const chunker = options . chunker ?? fixedSize ( )
325
340
const chunkValidator = options . chunkValidator ?? defaultChunkValidator ( )
@@ -337,7 +352,9 @@ export async function * importer (source: ImportCandidateStream, blockstore: Wri
337
352
blockWriteConcurrency,
338
353
reduceSingleLeafToSelf,
339
354
cidVersion,
340
- onProgress : options . onProgress
355
+ onProgress : options . onProgress ,
356
+ dirBuilder : options . dirBuilder ,
357
+ fileBuilder : options . fileBuilder
341
358
} )
342
359
const buildTree : TreeBuilder = options . treeBuilder ?? defaultTreeBuilder ( {
343
360
wrapWithDirectory,
0 commit comments