diff --git a/lib/content/read.js b/lib/content/read.js index 6cb7b08..23bc013 100644 --- a/lib/content/read.js +++ b/lib/content/read.js @@ -52,7 +52,7 @@ function readStream (cache, integrity, opts) { module.exports.hasContent = hasContent function hasContent (cache, integrity) { if (!integrity) { return BB.resolve(false) } - return pickContentSri(cache, integrity) + return pickContentSri(cache, integrity, true) .catch({code: 'ENOENT'}, () => false) .catch({code: 'EPERM'}, err => { if (process.platform !== 'win32') { @@ -64,7 +64,7 @@ function hasContent (cache, integrity) { } module.exports._pickContentSri = pickContentSri -function pickContentSri (cache, integrity) { +function pickContentSri (cache, integrity, checkFs) { const sri = ssri.parse(integrity) // If `integrity` has multiple entries, pick the first digest // with available local data. @@ -72,10 +72,14 @@ function pickContentSri (cache, integrity) { const digests = sri[algo] if (digests.length <= 1) { const cpath = contentPath(cache, digests[0]) - return fs.lstatAsync(cpath).then(() => digests[0]) + if (checkFs) { + return fs.lstatAsync(cpath).then(() => digests[0]) + } else { + return BB.resolve(digests[0]) + } } else { return BB.any(sri[sri.pickAlgorithm()].map(meta => { - return pickContentSri(cache, meta) + return pickContentSri(cache, meta, true) })) } }