cacache 18.0.2 → 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.
@@ -71,7 +71,7 @@ function readStream (cache, integrity, opts = {}) {
71
71
  module.exports.copy = copy
72
72
 
73
73
  function copy (cache, integrity, dest) {
74
- return withContentSri(cache, integrity, (cpath, sri) => {
74
+ return withContentSri(cache, integrity, (cpath) => {
75
75
  return fs.copyFile(cpath, dest)
76
76
  })
77
77
  }
@@ -160,7 +160,7 @@ async function makeTmp (cache, opts) {
160
160
  }
161
161
  }
162
162
 
163
- async function moveToDestination (tmp, cache, sri, opts) {
163
+ async function moveToDestination (tmp, cache, sri) {
164
164
  const destination = contentPath(cache, sri)
165
165
  const destDir = path.dirname(destination)
166
166
  if (moveOperations.has(destination)) {
@@ -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))
@@ -240,7 +246,7 @@ async function bucketEntries (bucket, filter) {
240
246
  return _bucketEntries(data, filter)
241
247
  }
242
248
 
243
- function _bucketEntries (data, filter) {
249
+ function _bucketEntries (data) {
244
250
  const entries = []
245
251
  data.split('\n').forEach((entry) => {
246
252
  if (!entry) {
package/lib/verify.js CHANGED
@@ -68,11 +68,11 @@ async function verify (cache, opts) {
68
68
  return stats
69
69
  }
70
70
 
71
- async function markStartTime (cache, opts) {
71
+ async function markStartTime () {
72
72
  return { startTime: new Date() }
73
73
  }
74
74
 
75
- async function markEndTime (cache, opts) {
75
+ async function markEndTime () {
76
76
  return { endTime: new Date() }
77
77
  }
78
78
 
@@ -213,7 +213,7 @@ async function rebuildIndex (cache, opts) {
213
213
  return stats
214
214
  }
215
215
 
216
- async function rebuildBucket (cache, bucket, stats, opts) {
216
+ async function rebuildBucket (cache, bucket, stats) {
217
217
  await truncate(bucket._path)
218
218
  // This needs to be serialized because cacache explicitly
219
219
  // lets very racy bucket conflicts clobber each other.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cacache",
3
- "version": "18.0.2",
3
+ "version": "18.0.4",
4
4
  "cache-version": {
5
5
  "content": "2",
6
6
  "index": "5"
@@ -26,7 +26,7 @@
26
26
  },
27
27
  "repository": {
28
28
  "type": "git",
29
- "url": "https://github.com/npm/cacache.git"
29
+ "url": "git+https://github.com/npm/cacache.git"
30
30
  },
31
31
  "keywords": [
32
32
  "cache",
@@ -60,7 +60,7 @@
60
60
  },
61
61
  "devDependencies": {
62
62
  "@npmcli/eslint-config": "^4.0.0",
63
- "@npmcli/template-oss": "4.21.3",
63
+ "@npmcli/template-oss": "4.22.0",
64
64
  "tap": "^16.0.0"
65
65
  },
66
66
  "engines": {
@@ -69,7 +69,7 @@
69
69
  "templateOSS": {
70
70
  "//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
71
71
  "windowsCI": false,
72
- "version": "4.21.3",
72
+ "version": "4.22.0",
73
73
  "publish": "true"
74
74
  },
75
75
  "author": "GitHub Inc.",