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

Commit f0ad6be

Browse files
dignifiedquiredaviddias
authored andcommitted
fixes
1 parent f8d1b2a commit f0ad6be

File tree

3 files changed

+26
-28
lines changed

3 files changed

+26
-28
lines changed

src/exporter.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
'use strict'
22

3-
const isIPFS = require('is-ipfs')
43
const traverse = require('pull-traverse')
54
const pull = require('pull-stream')
65

src/exporters/file.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,22 @@ const UnixFS = require('ipfs-unixfs')
44
const pull = require('pull-stream')
55

66
function extractContent (node) {
7-
const raw = UnixFS.unmarshal(node.data)
8-
return pull.values([raw.data])
7+
return UnixFS.unmarshal(node.data).data
98
}
109

1110
// Logic to export a single (possibly chunked) unixfs file.
1211
module.exports = (node, name, ds) => {
1312
let content
1413

1514
if (node.links.length === 0) {
16-
content = extractContent(node)
15+
const c = extractContent(node)
16+
content = pull.values([c])
1717
} else {
1818
content = pull(
1919
pull.values(node.links),
2020
pull.map((link) => ds.getStream(link.hash)),
2121
pull.flatten(),
22-
pull.map(extractContent),
23-
pull.flatten()
22+
pull.map(extractContent)
2423
)
2524
}
2625

test/test-importer.js

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -241,28 +241,28 @@ module.exports = function (repo) {
241241

242242
// need to sort as due to parallel storage the order
243243
// can vary
244-
const sorted = stringifyMh(files).sort((a, b) => a.path < b.path)
245-
expect(sorted).to.be.eql([{
246-
path: 'pam/pum/200Bytes.txt',
247-
multihash: 'QmQmZQxSKQppbsWfVzBvg59Cn3DKtsNVQ94bjAxg2h3Lb8',
248-
size: 211
249-
}, {
250-
path: 'pam/pum/1.2MiB.txt',
251-
multihash: 'QmW7BDxEbGqxxSYVtn3peNPQgdDXbWkoQ6J1EFYAEuQV3Q',
252-
size: 1258318
253-
}, {
254-
path: 'pam/pum',
255-
multihash: 'QmY8a78tx6Tk6naDgWCgTsd9EqGrUJRrH7dDyQhjyrmH2i',
256-
size: 1258642
257-
}, {
258-
path: 'pam/1.2MiB.txt',
259-
multihash: 'QmW7BDxEbGqxxSYVtn3peNPQgdDXbWkoQ6J1EFYAEuQV3Q',
260-
size: 1258318
261-
}, {
262-
path: 'pam',
263-
multihash: 'QmRgdtzNx1H1BPJqShdhvWZ2D4DA2HUgZJ3XLtoXei27Av',
264-
size: 2517065
265-
}])
244+
stringifyMh(files).forEach((file) => {
245+
if (file.path === 'pam/pum/200Bytes.txt') {
246+
expect(file.multihash).to.be.eql('QmQmZQxSKQppbsWfVzBvg59Cn3DKtsNVQ94bjAxg2h3Lb8')
247+
expect(file.size).to.be.eql(211)
248+
}
249+
if (file.path === 'pam/pum/1.2MiB.txt') {
250+
expect(file.multihash).to.be.eql('QmW7BDxEbGqxxSYVtn3peNPQgdDXbWkoQ6J1EFYAEuQV3Q')
251+
expect(file.size).to.be.eql(1258318)
252+
}
253+
if (file.path === 'pam/pum') {
254+
expect(file.multihash).to.be.eql('QmY8a78tx6Tk6naDgWCgTsd9EqGrUJRrH7dDyQhjyrmH2i')
255+
expect(file.size).to.be.eql(1258642)
256+
}
257+
if (file.path === 'pam/1.2MiB.txt') {
258+
expect(file.multihash).to.be.eql('QmW7BDxEbGqxxSYVtn3peNPQgdDXbWkoQ6J1EFYAEuQV3Q')
259+
expect(file.size).to.be.eql(1258318)
260+
}
261+
if (file.path === 'pam') {
262+
expect(file.multihash).to.be.eql('QmRgdtzNx1H1BPJqShdhvWZ2D4DA2HUgZJ3XLtoXei27Av')
263+
expect(file.size).to.be.eql(2517065)
264+
}
265+
})
266266

267267
done()
268268
})

0 commit comments

Comments
 (0)