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

Commit

Permalink
fix(dag): check dag.put options for plain object (#1480)
Browse files Browse the repository at this point in the history
* fix(dag): check dag.put options for plain object

fixes #1479

* fix(dag): check for undefined options value

* fix: increase timeout for pin after hook

License: MIT
Signed-off-by: Alan Shaw <alan@tableflip.io>
  • Loading branch information
negamaxi authored and alanshaw committed Aug 8, 2018
1 parent ff59a2f commit d0b671b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/core/components/dag.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ module.exports = function dag (self) {
put: promisify((dagNode, options, callback) => {
if (typeof options === 'function') {
callback = options
} else if (options.cid && (options.format || options.hashAlg)) {
options = {}
} else if (options && options.cid && (options.format || options.hashAlg)) {
return callback(new Error('Can\'t put dag node. Please provide either `cid` OR `format` and `hashAlg` options.'))
} else if ((options.format && !options.hashAlg) || (!options.format && options.hashAlg)) {
} else if (options && ((options.format && !options.hashAlg) || (!options.format && options.hashAlg))) {
return callback(new Error('Can\'t put dag node. Please provide `format` AND `hashAlg` options.'))
}
options = options || {}

const optionDefaults = {
format: 'dag-cbor',
Expand Down
5 changes: 4 additions & 1 deletion test/core/pin.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,10 @@ describe('pin', function () {
})
})

after(done => ipfs.stop(done))
after(function (done) {
this.timeout(20 * 1000)
ipfs.stop(done)
})

describe('isPinnedWithType', function () {
beforeEach(function () {
Expand Down

0 comments on commit d0b671b

Please sign in to comment.