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

Commit

Permalink
fix: choose import strategy in ipfs.add (#2541)
Browse files Browse the repository at this point in the history
* fix: choose import strategy in ipfs.add

The interface spec says you should pass a `trickle` boolean to
`ipfs.add` to get a trickle DAG, this PR makes us actually do that
instead of passing `strategy: 'whatever'`.

* fix: remove trickle arg before passing to importer
  • Loading branch information
achingbrain committed Oct 17, 2019
1 parent fe43d73 commit e2e6701
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/cli/commands/add.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ module.exports = {
argv.resolve((async () => {
const ipfs = await argv.getIpfs()
const options = {
strategy: argv.trickle ? 'trickle' : 'balanced',
trickle: argv.trickle,
shardSplitThreshold: argv.enableShardingExperiment
? argv.shardSplitThreshold
: Infinity,
Expand Down
7 changes: 7 additions & 0 deletions src/core/components/files-regular/add-async-iterator.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ module.exports = function (self) {
? 1000
: Infinity
}, options, {
strategy: 'balanced',
chunker: chunkerOptions.chunker,
chunkerOptions: chunkerOptions.chunkerOptions
})
Expand All @@ -30,6 +31,12 @@ module.exports = function (self) {
opts.cidVersion = 1
}

if (opts.trickle) {
opts.strategy = 'trickle'
}

delete opts.trickle

let total = 0

const prog = opts.progress || noop
Expand Down
2 changes: 1 addition & 1 deletion src/http/api/resources/files-regular.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ exports.add = {
wrapWithDirectory: request.query['wrap-with-directory'],
pin: request.query.pin,
chunker: request.query.chunker,
strategy: request.query.trickle ? 'trickle' : 'balanced',
trickle: request.query.trickle,
preload: request.query.preload
})
},
Expand Down

0 comments on commit e2e6701

Please sign in to comment.