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

Commit

Permalink
fix: correct raw leaves setting (#3401)
Browse files Browse the repository at this point in the history
If raw-leaves is unset, default to true if cid version is > 0.

This is in line with go-IPFS and is what the importer used to do internally.
  • Loading branch information
achingbrain committed Nov 16, 2020
1 parent 39cad4b commit c0703ef
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
7 changes: 5 additions & 2 deletions packages/ipfs-cli/src/commands/add.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,7 @@ module.exports = {
},
'raw-leaves': {
type: 'boolean',
describe: 'Use raw blocks for leaf nodes. (experimental)',
default: false
describe: 'Use raw blocks for leaf nodes. (experimental)'
},
'cid-version': {
type: 'integer',
Expand Down Expand Up @@ -241,6 +240,10 @@ module.exports = {
}
}

if (options.rawLeaves == null) {
options.rawLeaves = cidVersion > 0
}

const source = file
? globSource(file, {
recursive,
Expand Down
3 changes: 2 additions & 1 deletion packages/ipfs-cli/test/add.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ describe('add', () => {

ipfs.addAll.withArgs(matchIterable(), {
...defaultOptions,
cidVersion: 1
cidVersion: 1,
rawLeaves: true
}).returns([{
cid,
path: 'README.md'
Expand Down

0 comments on commit c0703ef

Please sign in to comment.