diff options
Diffstat (limited to 'deps/npm/node_modules/cacache/lib/content')
-rw-r--r-- | deps/npm/node_modules/cacache/lib/content/read.js | 5 | ||||
-rw-r--r-- | deps/npm/node_modules/cacache/lib/content/rm.js | 10 | ||||
-rw-r--r-- | deps/npm/node_modules/cacache/lib/content/write.js | 11 |
3 files changed, 17 insertions, 9 deletions
diff --git a/deps/npm/node_modules/cacache/lib/content/read.js b/deps/npm/node_modules/cacache/lib/content/read.js index 0ba19ac6e9..14ca7d905d 100644 --- a/deps/npm/node_modules/cacache/lib/content/read.js +++ b/deps/npm/node_modules/cacache/lib/content/read.js @@ -7,6 +7,7 @@ const fs = require('graceful-fs') const PassThrough = require('stream').PassThrough const pipe = BB.promisify(require('mississippi').pipe) const ssri = require('ssri') +const Y = require('../util/y.js') BB.promisifyAll(fs) @@ -86,7 +87,7 @@ function pickContentSri (cache, integrity) { } function sizeError (expected, found) { - var err = new Error('stream data size mismatch') + var err = new Error(Y`Bad data size: expected inserted data to be ${expected} bytes, but got ${found} instead`) err.expected = expected err.found = found err.code = 'EBADSIZE' @@ -94,7 +95,7 @@ function sizeError (expected, found) { } function integrityError (sri, path) { - var err = new Error(`Integrity verification failed for ${sri} (${path})`) + var err = new Error(Y`Integrity verification failed for ${sri} (${path})`) err.code = 'EINTEGRITY' err.sri = sri err.path = path diff --git a/deps/npm/node_modules/cacache/lib/content/rm.js b/deps/npm/node_modules/cacache/lib/content/rm.js index a8903dc0e3..12cf158235 100644 --- a/deps/npm/node_modules/cacache/lib/content/rm.js +++ b/deps/npm/node_modules/cacache/lib/content/rm.js @@ -9,9 +9,13 @@ const rimraf = BB.promisify(require('rimraf')) module.exports = rm function rm (cache, integrity) { return hasContent(cache, integrity).then(content => { - const sri = content.sri - if (sri) { - return rimraf(contentPath(cache, sri)) + if (content) { + const sri = content.sri + if (sri) { + return rimraf(contentPath(cache, sri)).then(() => true) + } + } else { + return false } }) } diff --git a/deps/npm/node_modules/cacache/lib/content/write.js b/deps/npm/node_modules/cacache/lib/content/write.js index 479d3e7f80..a79ae92902 100644 --- a/deps/npm/node_modules/cacache/lib/content/write.js +++ b/deps/npm/node_modules/cacache/lib/content/write.js @@ -13,6 +13,7 @@ const rimraf = BB.promisify(require('rimraf')) const ssri = require('ssri') const to = require('mississippi').to const uniqueFilename = require('unique-filename') +const Y = require('../util/y.js') const writeFileAsync = BB.promisify(fs.writeFile) @@ -21,7 +22,7 @@ function write (cache, data, opts) { opts = opts || {} if (opts.algorithms && opts.algorithms.length > 1) { throw new Error( - 'opts.algorithms only supports a single algorithm for now' + Y`opts.algorithms only supports a single algorithm for now` ) } if (typeof opts.size === 'number' && data.length !== opts.size) { @@ -58,7 +59,7 @@ function writeStream (cache, opts) { }, cb => { inputStream.end(() => { if (!allDone) { - const e = new Error('Input stream was empty') + const e = new Error(Y`Cache input stream was empty`) e.code = 'ENODATA' return ret.emit('error', e) } @@ -143,7 +144,7 @@ function moveToDestination (tmp, cache, sri, opts, errCheck) { } function sizeError (expected, found) { - var err = new Error('stream data size mismatch') + var err = new Error(Y`Bad data size: expected inserted data to be ${expected} bytes, but got ${found} instead`) err.expected = expected err.found = found err.code = 'EBADSIZE' @@ -151,7 +152,9 @@ function sizeError (expected, found) { } function checksumError (expected, found) { - var err = new Error('checksum failed') + var err = new Error(Y`Integrity check failed: + Wanted: ${expected} + Found: ${found}`) err.code = 'EINTEGRITY' err.expected = expected err.found = found |