Comparing version 11.3.1 to 11.3.2
@@ -43,2 +43,3 @@ // This is the base class that the other fetcher types in lib | ||
const _tarballFromResolved = Symbol.for('pacote.Fetcher._tarballFromResolved') | ||
const _cacheFetches = Symbol.for('pacote.Fetcher._cacheFetches') | ||
@@ -170,4 +171,4 @@ class FetcherBase { | ||
// private, should be overridden. | ||
// Note that they should *not* calculate or check integrity, but *just* | ||
// return the raw tarball data stream. | ||
// Note that they should *not* calculate or check integrity or cache, | ||
// but *just* return the raw tarball data stream. | ||
[_tarballFromResolved] () { | ||
@@ -179,13 +180,7 @@ throw this.notImplementedError | ||
tarball () { | ||
return this.tarballStream(stream => new Promise((res, rej) => { | ||
const buf = [] | ||
stream.on('error', er => rej(er)) | ||
stream.on('end', () => { | ||
const data = Buffer.concat(buf) | ||
data.integrity = this.integrity && String(this.integrity) | ||
data.resolved = this.resolved | ||
data.from = this.from | ||
return res(data) | ||
}) | ||
stream.on('data', d => buf.push(d)) | ||
return this.tarballStream(stream => stream.concat().then(data => { | ||
data.integrity = this.integrity && String(this.integrity) | ||
data.resolved = this.resolved | ||
data.from = this.from | ||
return data | ||
})) | ||
@@ -200,2 +195,6 @@ } | ||
get [_cacheFetches] () { | ||
return true | ||
} | ||
[_istream] (stream) { | ||
@@ -210,3 +209,27 @@ // everyone will need one of these, either for verifying or calculating | ||
istream.on('integrity', i => this.integrity = i) | ||
return stream.on('error', er => istream.emit('error', er)).pipe(istream) | ||
stream.on('error', er => istream.emit('error', er)) | ||
// if not caching this, just pipe through to the istream and return it | ||
if (!this.opts.cache || !this[_cacheFetches]) | ||
return stream.pipe(istream) | ||
// we have to return a stream that gets ALL the data, and proxies errors, | ||
// but then pipe from the original tarball stream into the cache as well. | ||
// To do this without losing any data, and since the cacache put stream | ||
// is not a passthrough, we have to pipe from the original stream into | ||
// the cache AFTER we pipe into the istream. Since the cache stream | ||
// has an asynchronous flush to write its contents to disk, we need to | ||
// defer the istream end until the cache stream ends. | ||
stream.pipe(istream, { end: false }) | ||
const cstream = cacache.put.stream( | ||
this.opts.cache, | ||
`pacote:tarball:${this.from}`, | ||
this.opts | ||
) | ||
stream.pipe(cstream) | ||
// defer istream end until after cstream | ||
// cache write errors should not crash the fetch, this is best-effort. | ||
cstream.promise().catch(() => {}).then(() => istream.end()) | ||
return istream | ||
} | ||
@@ -240,3 +263,5 @@ | ||
// TODO: check error class, once those are rolled out to our deps | ||
return this.isDataCorruptionError(er) || er.code === 'ENOENT' | ||
return this.isDataCorruptionError(er) || | ||
er.code === 'ENOENT' || | ||
er.code === 'EISDIR' | ||
} | ||
@@ -243,0 +268,0 @@ |
@@ -11,2 +11,3 @@ const Fetcher = require('./fetcher.js') | ||
const _cacheFetches = Symbol.for('pacote.Fetcher._cacheFetches') | ||
const _headers = Symbol('_headers') | ||
@@ -25,2 +26,8 @@ class RemoteFetcher extends Fetcher { | ||
// Don't need to cache tarball fetches in pacote, because make-fetch-happen | ||
// will write into cacache anyway. | ||
get [_cacheFetches] () { | ||
return false | ||
} | ||
[_tarballFromResolved] () { | ||
@@ -27,0 +34,0 @@ const stream = new Minipass() |
{ | ||
"name": "pacote", | ||
"version": "11.3.1", | ||
"version": "11.3.2", | ||
"description": "JavaScript package downloader", | ||
@@ -20,5 +20,3 @@ "author": "Isaac Z. Schlueter <i@izs.me> (https://izs.me)", | ||
"timeout": 300, | ||
"check-coverage": true, | ||
"coverage-map": "map.js", | ||
"esm": false | ||
"coverage-map": "map.js" | ||
}, | ||
@@ -28,4 +26,3 @@ "devDependencies": { | ||
"npm-registry-mock": "^1.3.1", | ||
"require-inject": "^1.4.4", | ||
"tap": "^14.11.0" | ||
"tap": "^15.0.4" | ||
}, | ||
@@ -54,3 +51,3 @@ "files": [ | ||
"npm-pick-manifest": "^6.0.0", | ||
"npm-registry-fetch": "^9.0.0", | ||
"npm-registry-fetch": "^10.0.0", | ||
"promise-retry": "^2.0.1", | ||
@@ -57,0 +54,0 @@ "read-package-json-fast": "^2.0.1", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
64950
3
1363
+ Addednpm-registry-fetch@10.1.2(transitive)
- Removed@npmcli/ci-detect@1.4.0(transitive)
- Removednpm-registry-fetch@9.0.0(transitive)
Updatednpm-registry-fetch@^10.0.0