You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 29, 2020. It is now read-only.
The interesting bits of this module are the various ways of building
DAGs for files and folders (flat, sharded, etc).
Sometimes we want to utilise bits of this logic to build DAGs without
having to reimplement big chunks of this module.
This PR allows the user to pass in functions to replace key parts of
this import pipeline.
Enables:
* ipfs-inactive/js-ipfs-mfs#73
* #46
@@ -145,8 +146,28 @@ The input's file paths and directory structure will be preserved in the [`dag-pb
145
146
-`blockWriteConcurrency` (positive integer, defaults to 10) How many blocks to hash and write to the block store concurrently. For small numbers of large files this should be high (e.g. 50).
146
147
-`fileImportConcurrency` (number, defaults to 50) How many files to import concurrently. For large numbers of small files this should be high (e.g. 50).
147
148
149
+
## Overriding internals
150
+
151
+
Several aspects of the importer are overridable by specifying functions as part of the options object with these keys:
152
+
153
+
-`chunkValidator` (function): Optional function that supports the signature `async function * (source, options)`
154
+
- It should yield `Buffer` objects constructed from the `source` or throw an `Error`
155
+
-`chunker` (function): Optional function that supports the signature `async function * (source, options)` where `source` is an async generator and `options` is an options object
156
+
- It should yield `Buffer` objects.
157
+
-`bufferImporter` (function): Optional function that supports the signature `async function * (entry, source, ipld, options)`
158
+
-`entry` is the `{ path, content }` entry, `source` is an async generator that yields Buffers
159
+
- It should yield functions that return a Promise that resolves to an object with the properties `{ cid, unixfs, size }` where `cid` is a [CID], `unixfs` is a [UnixFS] entry and `size` is a `Number` that represents the serialized size of the [IPLD] node that holds the buffer data.
160
+
- Values will be pulled from this generator in parallel - the amount of parallelisation is controlled by the `blockWriteConcurrency` option (default: 10)
161
+
-`dagBuilder` (function): Optional function that supports the signature `async function * (source, ipld, options)`
162
+
- It should yield a `function` that returns a `Promise` that resolves to `{ cid, path, unixfs, node }` where `cid` is a `CID`, `path` is a string, `unixfs` is a UnixFS entry and `node` is a `DAGNode`.
163
+
- Values will be pulled from this generator in parallel - the amount of parallelisation is controlled by the `fileImportConcurrency` option (default: 50)
164
+
-`treeBuilder` (function): Optional function that supports the signature `async function * (source, ipld, options)`
165
+
- It should yield an object with the properties `{ cid, path, unixfs, size }` where `cid` is a `CID`, `path` is a string, `unixfs` is a UnixFS entry and `size` is a `Number`.
0 commit comments