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

Commit

Permalink
fix: support .Size property
Browse files Browse the repository at this point in the history
At some point in the distant past we supported a `.Size` property for
`DAGLink`s so this PR adds that back in.
  • Loading branch information
achingbrain authored and vmx committed May 20, 2019
1 parent c2ad35a commit 30b5d55
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
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 @@ -443,5 +443,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)
})
})
}

0 comments on commit 30b5d55

Please sign in to comment.