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

Commit

Permalink
Remove unnecessary readable stream.
Browse files Browse the repository at this point in the history
  • Loading branch information
hackergrrl committed May 19, 2016
1 parent 4c2d557 commit 5516717
Showing 1 changed file with 5 additions and 20 deletions.
25 changes: 5 additions & 20 deletions src/http-api/resources/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

const bs58 = require('bs58')
const ndjson = require('ndjson')
const Readable = require('stream').Readable
const multipart = require('ipfs-multipart')
const debug = require('debug')
const log = debug('http-api:files')
Expand Down Expand Up @@ -50,26 +49,12 @@ exports.add = {
})

parser.on('file', (fileName, fileStream) => {
var rs = new Readable()
var init = false
rs._read = () => {
if (init) {
return
}
init = true
var filePair = {
path: fileName,
stream: fileStream
}
fileStream.on('data', (data) => {
rs.push(data)
file = true
})
fileStream.on('end', () => {
rs.push(null)
var filePair = {
path: fileName,
stream: rs
}
fileAdder.write(filePair)
})
file = true
fileAdder.write(filePair)
})

parser.on('end', () => {
Expand Down

0 comments on commit 5516717

Please sign in to comment.