diff --git a/src/http-api/index.js b/src/http-api/index.js index d49582bb97..b9b5c98b9a 100644 --- a/src/http-api/index.js +++ b/src/http-api/index.js @@ -19,7 +19,6 @@ exports = module.exports = function HttpApi (repo) { this.start = (callback) => { if (typeof repo === 'string') { - console.log('here') repo = new IPFSRepo(repo, {stores: fsbs}) } diff --git a/src/http-api/resources/files.js b/src/http-api/resources/files.js index c971e01eaa..72ed68aaad 100644 --- a/src/http-api/resources/files.js +++ b/src/http-api/resources/files.js @@ -17,8 +17,7 @@ exports.add = { const parser = multipart.reqParser(request.payload) - var file = false - var written = 0 + var filesSeen = 0 var serialize = ndjson.serialize() // hapi doesn't permit object streams: http://hapijs.com/api#replyerr-result @@ -31,11 +30,11 @@ exports.add = { Name: file.path, Hash: bs58.encode(file.multihash).toString() }) - written++ + filesSeen++ }) fileAdder.on('end', () => { - if (written === 0 && file) { + if (!filesSeen) { return reply({ Message: 'Failed to add files', Code: 0 @@ -53,12 +52,11 @@ exports.add = { path: fileName, stream: fileStream } - file = true fileAdder.write(filePair) }) parser.on('end', () => { - if (!file) { + if (!filesSeen) { return reply("File argument 'data' is required").code(400).takeover() } fileAdder.end()