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

Commit d0b671b

Browse files
negamaxialanshaw
authored andcommitted
fix(dag): check dag.put options for plain object (#1480)
* 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>
1 parent ff59a2f commit d0b671b

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/core/components/dag.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@ module.exports = function dag (self) {
1111
put: promisify((dagNode, options, callback) => {
1212
if (typeof options === 'function') {
1313
callback = options
14-
} else if (options.cid && (options.format || options.hashAlg)) {
14+
options = {}
15+
} else if (options && options.cid && (options.format || options.hashAlg)) {
1516
return callback(new Error('Can\'t put dag node. Please provide either `cid` OR `format` and `hashAlg` options.'))
16-
} else if ((options.format && !options.hashAlg) || (!options.format && options.hashAlg)) {
17+
} else if (options && ((options.format && !options.hashAlg) || (!options.format && options.hashAlg))) {
1718
return callback(new Error('Can\'t put dag node. Please provide `format` AND `hashAlg` options.'))
1819
}
20+
options = options || {}
1921

2022
const optionDefaults = {
2123
format: 'dag-cbor',

test/core/pin.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,10 @@ describe('pin', function () {
8181
})
8282
})
8383

84-
after(done => ipfs.stop(done))
84+
after(function (done) {
85+
this.timeout(20 * 1000)
86+
ipfs.stop(done)
87+
})
8588

8689
describe('isPinnedWithType', function () {
8790
beforeEach(function () {

0 commit comments

Comments
 (0)