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

add support for ipfs files stat --with-local #695

Merged
merged 2 commits into from
Mar 14, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
9 changes: 8 additions & 1 deletion src/files/stat.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
'use strict'

const promisify = require('promisify-es6')
const _ = require('lodash')

const transform = function (res, callback) {
callback(null, {
type: res.Type,
blocks: res.Blocks,
size: res.Size,
hash: res.Hash,
cumulativeSize: res.CumulativeSize
cumulativeSize: res.CumulativeSize,
withLocality: res.WithLocality || false,
local: res.Local || undefined,
sizeLocal: res.SizeLocal || undefined
})
}

Expand All @@ -18,6 +22,9 @@ module.exports = (send) => {
callback = opts
opts = {}
}

opts = _.mapKeys(opts, (v, k) => _.kebabCase(k))

send.andTransform({
path: 'files/stat',
args: args,
Expand Down
5 changes: 4 additions & 1 deletion test/files.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,10 @@ describe('.files (the MFS API part)', function () {
size: 12,
cumulativeSize: 20,
blocks: 0,
type: 'file'
type: 'file',
withLocality: false,
local: undefined,
sizeLocal: undefined
})

done()
Expand Down