This repository was archived by the owner on Mar 10, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +24
-7
lines changed Expand file tree Collapse file tree 2 files changed +24
-7
lines changed Original file line number Diff line number Diff line change 11'use strict'
22
33const promisify = require ( 'promisify-es6' )
4+ const _ = require ( 'lodash' )
5+ const streamToValue = require ( '../utils/stream-to-value' )
46
57const transform = function ( res , callback ) {
6- callback ( null , {
7- type : res . Type ,
8- blocks : res . Blocks ,
9- size : res . Size ,
10- hash : res . Hash ,
11- cumulativeSize : res . CumulativeSize
8+ return streamToValue ( res , ( err , data ) => {
9+ if ( err ) {
10+ return callback ( err )
11+ }
12+
13+ callback ( null , {
14+ type : data [ 0 ] . Type ,
15+ blocks : data [ 0 ] . Blocks ,
16+ size : data [ 0 ] . Size ,
17+ hash : data [ 0 ] . Hash ,
18+ cumulativeSize : data [ 0 ] . CumulativeSize ,
19+ withLocality : data [ 0 ] . WithLocality || false ,
20+ local : data [ 0 ] . Local || null ,
21+ sizeLocal : data [ 0 ] . SizeLocal || null
22+ } )
1223 } )
1324}
1425
@@ -18,6 +29,9 @@ module.exports = (send) => {
1829 callback = opts
1930 opts = { }
2031 }
32+
33+ opts = _ . mapKeys ( opts , ( v , k ) => _ . kebabCase ( k ) )
34+
2135 send . andTransform ( {
2236 path : 'files/stat' ,
2337 args : args ,
Original file line number Diff line number Diff line change @@ -282,7 +282,10 @@ describe('.files (the MFS API part)', function () {
282282 size : 12 ,
283283 cumulativeSize : 20 ,
284284 blocks : 0 ,
285- type : 'file'
285+ type : 'file' ,
286+ withLocality : false ,
287+ local : undefined ,
288+ sizeLocal : undefined
286289 } )
287290
288291 done ( )
You can’t perform that action at this time.
0 commit comments