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

Commit

Permalink
Make variable names clearer.
Browse files Browse the repository at this point in the history
  • Loading branch information
hackergrrl committed May 19, 2016
1 parent 5516717 commit 1bbb384
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
1 change: 0 additions & 1 deletion src/http-api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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})
}

Expand Down
10 changes: 4 additions & 6 deletions src/http-api/resources/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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()
Expand Down

0 comments on commit 1bbb384

Please sign in to comment.