From c07abd3a739e2ade464b3665c983a40613c74901 Mon Sep 17 00:00:00 2001 From: achingbrain Date: Wed, 16 Oct 2019 17:33:30 +0100 Subject: [PATCH 1/2] 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'`. --- src/cli/commands/add.js | 2 +- src/core/components/files-regular/add-async-iterator.js | 6 ++++++ src/http/api/resources/files-regular.js | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/cli/commands/add.js b/src/cli/commands/add.js index a76ba3a7f8..3bfe6f9866 100644 --- a/src/cli/commands/add.js +++ b/src/cli/commands/add.js @@ -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, diff --git a/src/core/components/files-regular/add-async-iterator.js b/src/core/components/files-regular/add-async-iterator.js index c5ab26bb38..d1f1ef3127 100644 --- a/src/core/components/files-regular/add-async-iterator.js +++ b/src/core/components/files-regular/add-async-iterator.js @@ -21,6 +21,7 @@ module.exports = function (self) { ? 1000 : Infinity }, options, { + strategy: 'balanced', chunker: chunkerOptions.chunker, chunkerOptions: chunkerOptions.chunkerOptions }) @@ -30,6 +31,11 @@ module.exports = function (self) { opts.cidVersion = 1 } + if (opts.trickle) { + opts.strategy = 'trickle' + delete opts.trickle + } + let total = 0 const prog = opts.progress || noop diff --git a/src/http/api/resources/files-regular.js b/src/http/api/resources/files-regular.js index 4aadc8f041..d71842b3ac 100644 --- a/src/http/api/resources/files-regular.js +++ b/src/http/api/resources/files-regular.js @@ -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 }) }, From 96bb3d1a272bcef3d8646492f69efb63caf731ac Mon Sep 17 00:00:00 2001 From: achingbrain Date: Thu, 17 Oct 2019 06:52:38 +0100 Subject: [PATCH 2/2] fix: remove trickle arg before passing to importer --- src/core/components/files-regular/add-async-iterator.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/core/components/files-regular/add-async-iterator.js b/src/core/components/files-regular/add-async-iterator.js index d1f1ef3127..e138a1cd66 100644 --- a/src/core/components/files-regular/add-async-iterator.js +++ b/src/core/components/files-regular/add-async-iterator.js @@ -33,9 +33,10 @@ module.exports = function (self) { if (opts.trickle) { opts.strategy = 'trickle' - delete opts.trickle } + delete opts.trickle + let total = 0 const prog = opts.progress || noop