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

Commit

Permalink
fix: regression caused by 322b756 (#591)
Browse files Browse the repository at this point in the history
  • Loading branch information
daviddias committed Sep 2, 2017
1 parent 70c91b7 commit 8affcfe
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 17 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,4 @@
"url": "https://github.com/ipfs/js-ipfs-api/issues"
},
"homepage": "https://github.com/ipfs/js-ipfs-api"
}
}
10 changes: 2 additions & 8 deletions src/files/create-add-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,8 @@ module.exports = (send) => {

ds.end = () => {
add(tuples, options, (err, res) => {
if (err) {
return ds.emit('error', err)
}

res.forEach((tuple) => {
ds.push(tuple)
})

if (err) { return ds.emit('error', err) }
res.forEach((tuple) => ds.push(tuple))
ds.push(null)
})
}
Expand Down
2 changes: 0 additions & 2 deletions src/object/new.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ module.exports = (send) => {
}

if (node.toJSON().multihash !== result.Hash) {
console.log(node.toJSON())
console.log(result)
return callback(new Error('multihashes do not match'))
}

Expand Down
11 changes: 6 additions & 5 deletions src/utils/get-files-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ const flatmap = require('flatmap')
const escape = require('glob-escape')

function headers (file) {
const name = encodeURIComponent(file.path) || ''
const header = {
'Content-Disposition': `file; filename="${name}"`
}
const name = file.path
? encodeURIComponent(file.path)
: ''

const header = { 'Content-Disposition': `file; filename="${name}"` }

if (file.dir || !file.content) {
header['Content-Type'] = 'application/x-directory'
Expand Down Expand Up @@ -49,7 +50,7 @@ function loadPaths (opts, file) {
const mg = new glob.sync.GlobSync(`${globEscapedDir}` + '**/*', {
follow: followSymlinks,
dot: opts.hidden,
ignore: (opts.ignore || []).map(function (ignoreGlob) {
ignore: (opts.ignore || []).map((ignoreGlob) => {
return globEscapedDir + ignoreGlob
})
})
Expand Down
3 changes: 2 additions & 1 deletion src/utils/request-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const request = require('./request')

function parseError (res, cb) {
const error = new Error(`Server responded with ${res.statusCode}`)

streamToJsonValue(res, (err, payload) => {
if (err) {
return cb(err)
Expand Down Expand Up @@ -61,8 +62,8 @@ function onRes (buffer, cb) {
}

function requestAPI (config, options, callback) {
options.qs = options.qs || {}
callback = once(callback)
options.qs = options.qs || {}

if (Array.isArray(options.files)) {
options.qs.recursive = true
Expand Down

0 comments on commit 8affcfe

Please sign in to comment.