cacache 18.0.1 → 18.0.3

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.
@@ -13,18 +13,20 @@ async function read (cache, integrity, opts = {}) {
13
13
  const { size } = opts
14
14
  const { stat, cpath, sri } = await withContentSri(cache, integrity, async (cpath, sri) => {
15
15
  // get size
16
- const stat = await fs.stat(cpath)
16
+ const stat = size ? { size } : await fs.stat(cpath)
17
17
  return { stat, cpath, sri }
18
18
  })
19
- if (typeof size === 'number' && stat.size !== size) {
20
- throw sizeError(size, stat.size)
21
- }
22
19
 
23
20
  if (stat.size > MAX_SINGLE_READ_SIZE) {
24
21
  return readPipeline(cpath, stat.size, sri, new Pipeline()).concat()
25
22
  }
26
23
 
27
24
  const data = await fs.readFile(cpath, { encoding: null })
25
+
26
+ if (stat.size !== data.length) {
27
+ throw sizeError(stat.size, data.length)
28
+ }
29
+
28
30
  if (!ssri.checkData(data, sri)) {
29
31
  throw integrityError(sri, cpath)
30
32
  }
@@ -55,13 +57,10 @@ function readStream (cache, integrity, opts = {}) {
55
57
  // Set all this up to run on the stream and then just return the stream
56
58
  Promise.resolve().then(async () => {
57
59
  const { stat, cpath, sri } = await withContentSri(cache, integrity, async (cpath, sri) => {
58
- // just stat to ensure it exists
59
- const stat = await fs.stat(cpath)
60
+ // get size
61
+ const stat = size ? { size } : await fs.stat(cpath)
60
62
  return { stat, cpath, sri }
61
63
  })
62
- if (typeof size === 'number' && size !== stat.size) {
63
- return stream.emit('error', sizeError(size, stat.size))
64
- }
65
64
 
66
65
  return readPipeline(cpath, stat.size, sri, stream)
67
66
  }).catch(err => stream.emit('error', err))
@@ -72,7 +71,7 @@ function readStream (cache, integrity, opts = {}) {
72
71
  module.exports.copy = copy
73
72
 
74
73
  function copy (cache, integrity, dest) {
75
- return withContentSri(cache, integrity, (cpath, sri) => {
74
+ return withContentSri(cache, integrity, (cpath) => {
76
75
  return fs.copyFile(cpath, dest)
77
76
  })
78
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)) {
@@ -240,7 +240,7 @@ async function bucketEntries (bucket, filter) {
240
240
  return _bucketEntries(data, filter)
241
241
  }
242
242
 
243
- function _bucketEntries (data, filter) {
243
+ function _bucketEntries (data) {
244
244
  const entries = []
245
245
  data.split('\n').forEach((entry) => {
246
246
  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.1",
3
+ "version": "18.0.3",
4
4
  "cache-version": {
5
5
  "content": "2",
6
6
  "index": "5"
@@ -16,7 +16,7 @@
16
16
  "snap": "tap",
17
17
  "coverage": "tap",
18
18
  "test-docker": "docker run -it --rm --name pacotest -v \"$PWD\":/tmp -w /tmp node:latest npm test",
19
- "lint": "eslint \"**/*.js\"",
19
+ "lint": "eslint \"**/*.{js,cjs,ts,mjs,jsx,tsx}\"",
20
20
  "npmclilint": "npmcli-lint",
21
21
  "lintfix": "npm run lint -- --fix",
22
22
  "postsnap": "npm run lintfix --",
@@ -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.19.0",
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.19.0",
72
+ "version": "4.22.0",
73
73
  "publish": "true"
74
74
  },
75
75
  "author": "GitHub Inc.",