Skip to content
This repository was archived by the owner on Feb 12, 2024. It is now read-only.

Commit e146a28

Browse files
authored
chore: upgrade unixfs-importer (#3373)
Restores changes to defaults removed from the importer to ensure CID compatibility with go-IPFS.
1 parent 2bd5368 commit e146a28

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

packages/interface-ipfs-core/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"dirty-chai": "^2.0.1",
4040
"err-code": "^2.0.3",
4141
"ipfs-unixfs": "^2.0.3",
42-
"ipfs-unixfs-importer": "^3.0.4",
42+
"ipfs-unixfs-importer": "^4.0.0",
4343
"ipfs-utils": "^4.0.0",
4444
"ipld-block": "^0.11.0",
4545
"ipld-dag-cbor": "^0.17.0",

packages/ipfs-core/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
"ipfs-repo": "^7.0.0",
7676
"ipfs-unixfs": "^2.0.3",
7777
"ipfs-unixfs-exporter": "^3.0.4",
78-
"ipfs-unixfs-importer": "^3.0.4",
78+
"ipfs-unixfs-importer": "^4.0.0",
7979
"ipfs-utils": "^4.0.0",
8080
"ipld": "^0.28.0",
8181
"ipld-block": "^0.11.0",

packages/ipfs-core/src/components/add-all/index.js

+17
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,23 @@ module.exports = ({ block, gcLock, preload, pin, options: constructorOptions })
4141
opts.strategy = 'trickle'
4242
}
4343

44+
if (opts.strategy === 'trickle') {
45+
opts.leafType = 'raw'
46+
opts.reduceSingleLeafToSelf = false
47+
}
48+
49+
if (opts.cidVersion > 0 && opts.rawLeaves === undefined) {
50+
// if the cid version is 1 or above, use raw leaves as this is
51+
// what go does.
52+
opts.rawLeaves = true
53+
}
54+
55+
if (opts.hashAlg !== undefined && opts.rawLeaves === undefined) {
56+
// if a non-default hash alg has been specified, use raw leaves as this is
57+
// what go does.
58+
opts.rawLeaves = true
59+
}
60+
4461
delete opts.trickle
4562

4663
if (opts.progress) {

0 commit comments

Comments
 (0)