Skip to content
This repository has been archived by the owner on Aug 11, 2021. It is now read-only.

fix: support .Size property #137

Merged
merged 1 commit into from
May 20, 2019
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
6 changes: 3 additions & 3 deletions src/dag-link/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ const DAGLink = require('./index')

function createDagLinkFromB58EncodedHash (link) {
return new DAGLink(
link.name ? link.name : link.Name,
link.size ? link.size : link.Tsize,
link.hash || link.Hash || link.multihash || link.cid
link.Name || link.name || '',
link.Tsize || link.Size || link.size || 0,
link.Hash || link.hash || link.multihash || link.cid
)
}

Expand Down
9 changes: 9 additions & 0 deletions test/dag-node-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -424,5 +424,14 @@ module.exports = (repo) => {
const deserializedObject = dagPB.util.deserialize(serializedObject)
expect(deserialized.toJSON()).to.deep.equal(deserializedObject.toJSON())
})

it('creates links from objects with .Size properties', () => {
const node = DAGNode.create(Buffer.from('some data'), [{
Hash: 'QmUxD5gZfKzm8UN4WaguAMAZjw2TzZ2ZUmcqm2qXPtais7',
Size: 9001
}])

expect(node.Links[0].Tsize).to.eql(9001)
})
})
}