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

Commit 5516717

Browse files
committed
Remove unnecessary readable stream.
1 parent 4c2d557 commit 5516717

File tree

1 file changed

+5
-20
lines changed

1 file changed

+5
-20
lines changed

src/http-api/resources/files.js

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
const bs58 = require('bs58')
44
const ndjson = require('ndjson')
5-
const Readable = require('stream').Readable
65
const multipart = require('ipfs-multipart')
76
const debug = require('debug')
87
const log = debug('http-api:files')
@@ -50,26 +49,12 @@ exports.add = {
5049
})
5150

5251
parser.on('file', (fileName, fileStream) => {
53-
var rs = new Readable()
54-
var init = false
55-
rs._read = () => {
56-
if (init) {
57-
return
58-
}
59-
init = true
52+
var filePair = {
53+
path: fileName,
54+
stream: fileStream
6055
}
61-
fileStream.on('data', (data) => {
62-
rs.push(data)
63-
file = true
64-
})
65-
fileStream.on('end', () => {
66-
rs.push(null)
67-
var filePair = {
68-
path: fileName,
69-
stream: rs
70-
}
71-
fileAdder.write(filePair)
72-
})
56+
file = true
57+
fileAdder.write(filePair)
7358
})
7459

7560
parser.on('end', () => {

0 commit comments

Comments
 (0)