cacache 18.0.3 → 18.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/lib/entry-index.js +12 -6
  2. package/package.json +1 -1
@@ -19,6 +19,9 @@ 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
+
22
25
  module.exports.NotFoundError = class NotFoundError extends Error {
23
26
  constructor (cache, key) {
24
27
  super(`No cache entry for ${key} found in ${cache}`)
@@ -182,15 +185,15 @@ function lsStream (cache) {
182
185
  // Set all this up to run on the stream and then just return the stream
183
186
  Promise.resolve().then(async () => {
184
187
  const buckets = await readdirOrEmpty(indexDir)
185
- await Promise.all(buckets.map(async (bucket) => {
188
+ await pMap(buckets, async (bucket) => {
186
189
  const bucketPath = path.join(indexDir, bucket)
187
190
  const subbuckets = await readdirOrEmpty(bucketPath)
188
- await Promise.all(subbuckets.map(async (subbucket) => {
191
+ await pMap(subbuckets, async (subbucket) => {
189
192
  const subbucketPath = path.join(bucketPath, subbucket)
190
193
 
191
194
  // "/cachename/<bucket 0xFF>/<bucket 0xFF>./*"
192
195
  const subbucketEntries = await readdirOrEmpty(subbucketPath)
193
- await Promise.all(subbucketEntries.map(async (entry) => {
196
+ await pMap(subbucketEntries, async (entry) => {
194
197
  const entryPath = path.join(subbucketPath, entry)
195
198
  try {
196
199
  const entries = await bucketEntries(entryPath)
@@ -213,9 +216,12 @@ function lsStream (cache) {
213
216
  }
214
217
  throw err
215
218
  }
216
- }))
217
- }))
218
- }))
219
+ },
220
+ { concurrency: lsStreamConcurrency })
221
+ },
222
+ { concurrency: lsStreamConcurrency })
223
+ },
224
+ { concurrency: lsStreamConcurrency })
219
225
  stream.end()
220
226
  return stream
221
227
  }).catch(err => stream.emit('error', err))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cacache",
3
- "version": "18.0.3",
3
+ "version": "18.0.4",
4
4
  "cache-version": {
5
5
  "content": "2",
6
6
  "index": "5"