Skip to content

Commit a88213e

Browse files
committedMay 18, 2022
fix: pass expected integrity to cacache
this allows cacache to clean up after an integrity error instead of abandoning the temp files like it does today
1 parent ec2db21 commit a88213e

File tree

1 file changed

+1
-7
lines changed

1 file changed

+1
-7
lines changed
 

‎lib/cache/entry.js

+1-7
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@ class CacheEntry {
255255
algorithms: this.options.algorithms,
256256
metadata: getMetadata(this.request, this.response, this.options),
257257
size,
258+
integrity: this.options.integrity,
258259
}
259260

260261
let body = null
@@ -273,11 +274,9 @@ class CacheEntry {
273274
},
274275
}))
275276

276-
let abortStream
277277
const onResume = () => {
278278
const tee = new Minipass()
279279
const cacheStream = cacache.put.stream(this.options.cachePath, this.key, cacheOpts)
280-
abortStream = cacheStream
281280
tee.pipe(cacheStream)
282281
// TODO if the cache write fails, log a warning but return the response anyway
283282
cacheStream.promise().then(cacheWriteResolve, cacheWriteReject)
@@ -287,11 +286,6 @@ class CacheEntry {
287286

288287
body.once('resume', onResume)
289288
body.once('end', () => body.removeListener('resume', onResume))
290-
this.response.body.on('error', (err) => {
291-
// listen for errors from the actual response and avoid writing data that we
292-
// know to be invalid to the cache
293-
abortStream.destroy(err)
294-
})
295289
} else {
296290
await cacache.index.insert(this.options.cachePath, this.key, null, cacheOpts)
297291
}

0 commit comments

Comments
 (0)
Please sign in to comment.