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

Commit c2be97d

Browse files
committed
fix: use correct input
1 parent b8d9d0f commit c2be97d

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

src/core/components/files-regular/add-pull-stream.js

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@
33
const importer = require('ipfs-unixfs-importer')
44
const kindOf = require('kind-of')
55
const CID = require('cids')
6-
const pull = require('pull-stream')
6+
const pullValues = require('pull-stream/sources/values')
7+
const pullMap = require('pull-stream/throughs/map')
8+
const pullAsyncMap = require('pull-stream/throughs/async-map')
9+
const pullFlatten = require('pull-stream/throughs/flatten')
10+
const pull = require('pull-stream/pull')
711
const toPull = require('stream-to-pull-stream')
812
const waterfall = require('async/waterfall')
913
const isStream = require('is-stream')
@@ -55,12 +59,12 @@ function normalizeContent (content, opts) {
5559
}
5660

5761
return content.map((data) => {
58-
if (supportsFileReader && kindOf(content) === 'file') {
59-
data = { path: '', content: toPull.source(streamFromFileReader(content)) }
62+
if (supportsFileReader && kindOf(data) === 'file') {
63+
data = { path: '', content: toPull.source(streamFromFileReader(data)) }
6064
}
6165
// Buffer input
6266
if (Buffer.isBuffer(data)) {
63-
data = { path: '', content: pull.values([data]) }
67+
data = { path: '', content: pullValues([data]) }
6468
}
6569

6670
// Readable stream input
@@ -74,7 +78,7 @@ function normalizeContent (content, opts) {
7478

7579
if (data && data.content && typeof data.content !== 'function') {
7680
if (Buffer.isBuffer(data.content)) {
77-
data.content = pull.values([data.content])
81+
data.content = pullValues([data.content])
7882
}
7983

8084
if (isStream.readable(data.content)) {
@@ -130,7 +134,7 @@ module.exports = function (self) {
130134
try {
131135
chunkerOptions = parseChunkerString(options.chunker)
132136
} catch (err) {
133-
return pull.map(() => { throw err })
137+
return pullMap(() => { throw err })
134138
}
135139
const opts = Object.assign({}, {
136140
shardSplitThreshold: self._options.EXPERIMENTAL.sharding
@@ -153,12 +157,12 @@ module.exports = function (self) {
153157

154158
opts.progress = progress
155159
return pull(
156-
pull.map(content => normalizeContent(content, opts)),
157-
pull.flatten(),
160+
pullMap(content => normalizeContent(content, opts)),
161+
pullFlatten(),
158162
importer(self._ipld, opts),
159-
pull.asyncMap((file, cb) => prepareFile(file, self, opts, cb)),
160-
pull.map(file => preloadFile(file, self, opts)),
161-
pull.asyncMap((file, cb) => pinFile(file, self, opts, cb))
163+
pullAsyncMap((file, cb) => prepareFile(file, self, opts, cb)),
164+
pullMap(file => preloadFile(file, self, opts)),
165+
pullAsyncMap((file, cb) => pinFile(file, self, opts, cb))
162166
)
163167
}
164168
}

0 commit comments

Comments
 (0)