This repository was archived by the owner on Mar 10, 2020. It is now read-only.
File tree 2 files changed +19
-2
lines changed 2 files changed +19
-2
lines changed Original file line number Diff line number Diff line change 73
73
"ipfs-multipart" : " ^0.3.0" ,
74
74
"ipfs-unixfs" : " ^0.3.0" ,
75
75
"ipfs-unixfs-exporter" : " ^0.40.0" ,
76
- "ipfs-unixfs-importer" : " ipfs/js-ipfs-unixfs-importer#support-dagnodes-as-content " ,
76
+ "ipfs-unixfs-importer" : " ipfs/js-ipfs-unixfs-importer#expose-internals-for-customisation " ,
77
77
"ipfs-utils" : " ^0.4.2" ,
78
78
"ipld-dag-pb" : " ^0.18.0" ,
79
79
"it-last" : " ^1.0.1" ,
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ const exporter = require('ipfs-unixfs-exporter')
18
18
const last = require ( 'it-last' )
19
19
const cp = require ( './cp' )
20
20
const rm = require ( './rm' )
21
+ const persist = require ( 'ipfs-unixfs-importer/src/utils/persist' )
21
22
22
23
const defaultOptions = {
23
24
flush : true ,
@@ -191,7 +192,23 @@ module.exports = (context) => {
191
192
}
192
193
}
193
194
} ,
194
- ( source ) => importer ( source , context . ipld , options ) ,
195
+ ( source ) => importer ( source , context . ipld , {
196
+ ...options ,
197
+ dagBuilder : async function * ( source , ipld , options ) {
198
+ for await ( const entry of source ) {
199
+ yield async function ( ) {
200
+ const cid = await persist ( entry . content , ipld , options )
201
+
202
+ return {
203
+ cid,
204
+ path : entry . path ,
205
+ unixfs : UnixFS . unmarshal ( entry . content . Data ) ,
206
+ node : entry . content
207
+ }
208
+ }
209
+ }
210
+ }
211
+ } ) ,
195
212
( nodes ) => last ( nodes )
196
213
)
197
214
You can’t perform that action at this time.
0 commit comments