Skip to content
This repository was archived by the owner on Mar 10, 2020. It is now read-only.
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 @@ -66,7 +66,7 @@
"joi": "^14.3.0",
"joi-browser": "^13.4.0",
"mortice": "^1.2.1",
"multicodec": "~0.5.1",
"multicodec": "~0.5.3",
"multihashes": "~0.4.14",
"once": "^1.4.0",
"promisify-es6": "^1.0.3",
Expand Down
8 changes: 8 additions & 0 deletions src/core/stat.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,5 +86,13 @@ const statters = {
sizeLocal: undefined,
withLocality: false
}
},
'dag-cbor': (file) => {
return {
cid: file.cid,
local: undefined,
sizeLocal: undefined,
withLocality: false
}
}
}
12 changes: 12 additions & 0 deletions test/stat.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const expect = chai.expect
const crypto = require('crypto')
const createMfs = require('./helpers/create-mfs')
const createShardedDirectory = require('./helpers/create-sharded-directory')
const mc = require('multicodec')

describe('stat', () => {
let mfs
Expand Down Expand Up @@ -160,4 +161,15 @@ describe('stat', () => {
expect(stats.type).to.equal('file')
expect(stats.size).to.equal(7)
})

it('stats a dag-cbor node', async () => {
const path = '/cbor.node'
const node = {}
const cid = await mfs.ipld.put(node, mc.getNumber('dag-cbor'))
await mfs.cp(`/ipfs/${cid}`, path)

const stats = await mfs.stat(path)

expect(stats.cid.toString()).to.equal(cid.toString())
})
})