Skip to content
This repository was archived by the owner on Mar 10, 2020. It is now read-only.

Commit 4159b90

Browse files
authored
fix: return the CID for dag-cbor nodes (#52)
1 parent 7910d19 commit 4159b90

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
"joi": "^14.3.0",
6767
"joi-browser": "^13.4.0",
6868
"mortice": "^1.2.1",
69-
"multicodec": "~0.5.1",
69+
"multicodec": "~0.5.3",
7070
"multihashes": "~0.4.14",
7171
"once": "^1.4.0",
7272
"promisify-es6": "^1.0.3",

src/core/stat.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,5 +86,13 @@ const statters = {
8686
sizeLocal: undefined,
8787
withLocality: false
8888
}
89+
},
90+
'dag-cbor': (file) => {
91+
return {
92+
cid: file.cid,
93+
local: undefined,
94+
sizeLocal: undefined,
95+
withLocality: false
96+
}
8997
}
9098
}

test/stat.spec.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const expect = chai.expect
77
const crypto = require('crypto')
88
const createMfs = require('./helpers/create-mfs')
99
const createShardedDirectory = require('./helpers/create-sharded-directory')
10+
const mc = require('multicodec')
1011

1112
describe('stat', () => {
1213
let mfs
@@ -160,4 +161,15 @@ describe('stat', () => {
160161
expect(stats.type).to.equal('file')
161162
expect(stats.size).to.equal(7)
162163
})
164+
165+
it('stats a dag-cbor node', async () => {
166+
const path = '/cbor.node'
167+
const node = {}
168+
const cid = await mfs.ipld.put(node, mc.getNumber('dag-cbor'))
169+
await mfs.cp(`/ipfs/${cid}`, path)
170+
171+
const stats = await mfs.stat(path)
172+
173+
expect(stats.cid.toString()).to.equal(cid.toString())
174+
})
163175
})

0 commit comments

Comments
 (0)