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

Commit

Permalink
Revert "test: Revert "Make variable names a bit clearer.""
Browse files Browse the repository at this point in the history
This reverts commit 4a15885.
  • Loading branch information
hackergrrl committed May 20, 2016
1 parent b4515d3 commit 2a178f5
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/http-api/resources/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ exports.add = {

const parser = multipart.reqParser(request.payload)

var file = false
var written = 0
var filesParsed = false
var filesAdded = 0

var serialize = ndjson.serialize()
// hapi doesn't permit object streams: http://hapijs.com/api#replyerr-result
Expand All @@ -31,11 +31,11 @@ exports.add = {
Name: file.path,
Hash: multihash.toB58String(file.multihash)
})
written++
filesAdded++
})

fileAdder.on('end', () => {
if (written === 0 && file) {
if (filesAdded === 0 && filesParsed) {
return reply({
Message: 'Failed to add files.',
Code: 0
Expand All @@ -53,12 +53,12 @@ exports.add = {
path: fileName,
stream: fileStream
}
file = true
filesParsed = true
fileAdder.write(filePair)
})

parser.on('end', () => {
if (!file) {
if (!filesParsed) {
return reply("File argument 'data' is required.").code(400).takeover()
}
fileAdder.end()
Expand Down

0 comments on commit 2a178f5

Please sign in to comment.