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

Commit

Permalink
fix: block put with CID as string (#2760)
Browse files Browse the repository at this point in the history
* fix: block put with CID as string

* chore: update interface-ipfs-core dep
  • Loading branch information
Alan Shaw authored Feb 10, 2020
1 parent d8be8bb commit 39d87c5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@
"form-data": "^3.0.0",
"go-ipfs-dep": "^0.4.23",
"hat": "0.0.3",
"interface-ipfs-core": "^0.131.7",
"interface-ipfs-core": "^0.132.0",
"ipfs-interop": "github:ipfs/interop#refactor/async-await",
"ipfsd-ctl": "github:ipfs/js-ipfsd-ctl#remove-option-normalisation",
"ncp": "^2.0.0",
Expand Down
5 changes: 3 additions & 2 deletions src/core/components/block/put.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
const Block = require('ipfs-block')
const multihashing = require('multihashing-async')
const CID = require('cids')
const isIPFS = require('is-ipfs')

module.exports = ({ blockService, gcLock, preload }) => {
return async function put (block, options) {
Expand All @@ -13,8 +14,8 @@ module.exports = ({ blockService, gcLock, preload }) => {
}

if (!Block.isBlock(block)) {
if (options.cid && CID.isCID(options.cid)) {
block = new Block(block, options.cid)
if (options.cid && isIPFS.cid(options.cid)) {
block = new Block(block, CID.isCID(options.cid) ? options.cid : new CID(options.cid))
} else {
const mhtype = options.mhtype || 'sha2-256'
const format = options.format || 'dag-pb'
Expand Down

0 comments on commit 39d87c5

Please sign in to comment.