+13
-6
lines changedFilter options
+13
-6
lines changed Original file line number Diff line number Diff line change
@@ -19,6 +19,10 @@ const hashToSegments = require('./util/hash-to-segments')
19
19
const indexV = require('../package.json')['cache-version'].index
20
20
const { moveFile } = require('@npmcli/fs')
21
21
22
+
const pMap = require('p-map')
23
+
const lsStreamConcurrency = 5
24
+
25
+
22
26
module.exports.NotFoundError = class NotFoundError extends Error {
23
27
constructor (cache, key) {
24
28
super(`No cache entry for ${key} found in ${cache}`)
@@ -182,15 +186,15 @@ function lsStream (cache) {
182
186
// Set all this up to run on the stream and then just return the stream
183
187
Promise.resolve().then(async () => {
184
188
const buckets = await readdirOrEmpty(indexDir)
185
-
await Promise.all(buckets.map(async (bucket) => {
189
+
await pMap(buckets, async (bucket) => {
186
190
const bucketPath = path.join(indexDir, bucket)
187
191
const subbuckets = await readdirOrEmpty(bucketPath)
188
-
await Promise.all(subbuckets.map(async (subbucket) => {
192
+
await pMap(subbuckets, async (subbucket) => {
189
193
const subbucketPath = path.join(bucketPath, subbucket)
190
194
191
195
// "/cachename/<bucket 0xFF>/<bucket 0xFF>./*"
192
196
const subbucketEntries = await readdirOrEmpty(subbucketPath)
193
-
await Promise.all(subbucketEntries.map(async (entry) => {
197
+
await pMap(subbucketEntries, async (entry) => {
194
198
const entryPath = path.join(subbucketPath, entry)
195
199
try {
196
200
const entries = await bucketEntries(entryPath)
@@ -213,9 +217,12 @@ function lsStream (cache) {
213
217
}
214
218
throw err
215
219
}
216
-
}))
217
-
}))
218
-
}))
220
+
},
221
+
{ concurrency: lsStreamConcurrency })
222
+
},
223
+
{ concurrency: lsStreamConcurrency })
224
+
},
225
+
{ concurrency: lsStreamConcurrency })
219
226
stream.end()
220
227
return stream
221
228
}).catch(err => stream.emit('error', err))
You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4