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

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dignifiedquire authored and daviddias committed Sep 8, 2016
1 parent f8d1b2a commit f0ad6be
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 28 deletions.
1 change: 0 additions & 1 deletion src/exporter.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'use strict'

const isIPFS = require('is-ipfs')
const traverse = require('pull-traverse')
const pull = require('pull-stream')

Expand Down
9 changes: 4 additions & 5 deletions src/exporters/file.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,22 @@ const UnixFS = require('ipfs-unixfs')
const pull = require('pull-stream')

function extractContent (node) {
const raw = UnixFS.unmarshal(node.data)
return pull.values([raw.data])
return UnixFS.unmarshal(node.data).data
}

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

if (node.links.length === 0) {
content = extractContent(node)
const c = extractContent(node)
content = pull.values([c])
} else {
content = pull(
pull.values(node.links),
pull.map((link) => ds.getStream(link.hash)),
pull.flatten(),
pull.map(extractContent),
pull.flatten()
pull.map(extractContent)
)
}

Expand Down
44 changes: 22 additions & 22 deletions test/test-importer.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,28 +241,28 @@ module.exports = function (repo) {

// need to sort as due to parallel storage the order
// can vary
const sorted = stringifyMh(files).sort((a, b) => a.path < b.path)
expect(sorted).to.be.eql([{
path: 'pam/pum/200Bytes.txt',
multihash: 'QmQmZQxSKQppbsWfVzBvg59Cn3DKtsNVQ94bjAxg2h3Lb8',
size: 211
}, {
path: 'pam/pum/1.2MiB.txt',
multihash: 'QmW7BDxEbGqxxSYVtn3peNPQgdDXbWkoQ6J1EFYAEuQV3Q',
size: 1258318
}, {
path: 'pam/pum',
multihash: 'QmY8a78tx6Tk6naDgWCgTsd9EqGrUJRrH7dDyQhjyrmH2i',
size: 1258642
}, {
path: 'pam/1.2MiB.txt',
multihash: 'QmW7BDxEbGqxxSYVtn3peNPQgdDXbWkoQ6J1EFYAEuQV3Q',
size: 1258318
}, {
path: 'pam',
multihash: 'QmRgdtzNx1H1BPJqShdhvWZ2D4DA2HUgZJ3XLtoXei27Av',
size: 2517065
}])
stringifyMh(files).forEach((file) => {
if (file.path === 'pam/pum/200Bytes.txt') {
expect(file.multihash).to.be.eql('QmQmZQxSKQppbsWfVzBvg59Cn3DKtsNVQ94bjAxg2h3Lb8')
expect(file.size).to.be.eql(211)
}
if (file.path === 'pam/pum/1.2MiB.txt') {
expect(file.multihash).to.be.eql('QmW7BDxEbGqxxSYVtn3peNPQgdDXbWkoQ6J1EFYAEuQV3Q')
expect(file.size).to.be.eql(1258318)
}
if (file.path === 'pam/pum') {
expect(file.multihash).to.be.eql('QmY8a78tx6Tk6naDgWCgTsd9EqGrUJRrH7dDyQhjyrmH2i')
expect(file.size).to.be.eql(1258642)
}
if (file.path === 'pam/1.2MiB.txt') {
expect(file.multihash).to.be.eql('QmW7BDxEbGqxxSYVtn3peNPQgdDXbWkoQ6J1EFYAEuQV3Q')
expect(file.size).to.be.eql(1258318)
}
if (file.path === 'pam') {
expect(file.multihash).to.be.eql('QmRgdtzNx1H1BPJqShdhvWZ2D4DA2HUgZJ3XLtoXei27Av')
expect(file.size).to.be.eql(2517065)
}
})

done()
})
Expand Down

0 comments on commit f0ad6be

Please sign in to comment.