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

fix: block put with CID as string #2760

Merged
merged 2 commits into from
Feb 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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