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 +14
-12
lines changed Expand file tree Collapse file tree 2 files changed +14
-12
lines changed Original file line number Diff line number Diff line change 56
56
"ipfs-multipart" : " ~0.1.0" ,
57
57
"ipfs-unixfs" : " ~0.1.16" ,
58
58
"ipfs-unixfs-importer" : " ~0.37.0" ,
59
- "ipfs-unixfs-exporter" : " ~0.35.0 " ,
59
+ "ipfs-unixfs-exporter" : " ~0.35.1 " ,
60
60
"ipld-dag-pb" : " ~0.15.0" ,
61
61
"is-pull-stream" : " ~0.0.0" ,
62
62
"is-stream" : " ^1.1.0" ,
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ const pull = require('pull-stream/pull')
11
11
const collect = require ( 'pull-stream/sinks/collect' )
12
12
const asyncMap = require ( 'pull-stream/throughs/async-map' )
13
13
const exporter = require ( 'ipfs-unixfs-exporter' )
14
+ const CID = require ( 'cids' )
14
15
const log = require ( 'debug' ) ( 'ipfs:mfs:stat' )
15
16
16
17
const defaultOptions = {
@@ -40,6 +41,18 @@ module.exports = (context) => {
40
41
} ) ,
41
42
42
43
asyncMap ( ( file , cb ) => {
44
+ if ( options . hash ) {
45
+ return cb ( null , {
46
+ hash : formatCid ( new CID ( file . hash ) , options . cidBase )
47
+ } )
48
+ }
49
+
50
+ if ( options . size ) {
51
+ return cb ( null , {
52
+ size : file . size
53
+ } )
54
+ }
55
+
43
56
loadNode ( context , {
44
57
cid : file . hash
45
58
} , ( err , result ) => {
@@ -51,18 +64,7 @@ module.exports = (context) => {
51
64
node, cid
52
65
} = result
53
66
54
- if ( options . hash ) {
55
- return cb ( null , {
56
- hash : formatCid ( cid , options . cidBase )
57
- } )
58
- } else if ( options . size ) {
59
- return cb ( null , {
60
- size : node . size
61
- } )
62
- }
63
-
64
67
const meta = unmarshal ( node . data )
65
-
66
68
let blocks = node . links . length
67
69
68
70
if ( meta . type === 'file' ) {
You can’t perform that action at this time.
0 commit comments