multiblob
Advanced tools
Comparing version 1.13.1 to 1.13.2
31
index.js
@@ -16,2 +16,3 @@ var cont = require('cont') | ||
var Read = require('pull-file') | ||
var Catch = require('pull-catch') | ||
@@ -25,6 +26,26 @@ var u = require('./util') | ||
function read (filename) { | ||
return ReadFile(filename) | ||
} | ||
/** | ||
* Wraps the `pull-file` function module with two changes: errors are redacted, | ||
* and any error except ENOENT (file not found) will be logged to the server. | ||
* | ||
* @param {...object} args - arguments to pass to `pull-file` | ||
* | ||
* @return {function} pull-stream source, to be consumed by a through or sink | ||
*/ | ||
function readFile (...args) { | ||
return pull( | ||
Read(...args), | ||
Catch(err => { | ||
if (err.code !== 'ENOENT') { | ||
console.error(err.toString()) | ||
} | ||
err.message = 'could not get blob' | ||
return false // pass along error | ||
}) | ||
) | ||
}; | ||
function toArray (h) { | ||
@@ -197,3 +218,3 @@ return Array.isArray(h) ? h : [h] | ||
else | ||
stream.resolve(Read(toPath(dir, opts.hash), { | ||
stream.resolve(readFile(toPath(dir, opts.hash), { | ||
start: opts.start, | ||
@@ -212,3 +233,3 @@ end: opts.end | ||
if(isEmptyHash(hash)) return pull.empty() | ||
return Read(toPath(dir, opts)) | ||
return readFile(toPath(dir, opts)) | ||
} | ||
@@ -215,0 +236,0 @@ var hash = opts.key || opts.hash |
{ | ||
"name": "multiblob", | ||
"description": "", | ||
"version": "1.13.1", | ||
"version": "1.13.2", | ||
"homepage": "https://github.com/dominictarr/multiblob", | ||
@@ -16,2 +16,3 @@ "repository": { | ||
"pull-cat": "^1.1.8", | ||
"pull-catch": "^1.0.0", | ||
"pull-defer": "^0.2.2", | ||
@@ -18,0 +19,0 @@ "pull-file": "^0.5.0", |
@@ -15,5 +15,11 @@ var tape = require('tape') | ||
var l = 100, random1 = [] | ||
while(l --) random1.push(crypto.randomBytes(1024)) | ||
var l = 100 | ||
random1 = [] | ||
random2 = [] | ||
while (l--) { | ||
random1.push(crypto.randomBytes(1024)) | ||
random2.push(crypto.randomBytes(1024)) | ||
} | ||
module.exports = function (alg) { | ||
@@ -30,2 +36,3 @@ | ||
var hash1 = hasher(random1) | ||
var hash2 = hasher(random2) | ||
@@ -50,2 +57,18 @@ tape('read a slice', function (t) { | ||
tape('error if requested hash is missing', function (t) { | ||
pull( | ||
pull(blobs.get(hash2)), | ||
pull.collect(function (err) { | ||
for (var key in err) { | ||
console.log(key, err[key]) | ||
} | ||
t.ok(err, 'error message exists') | ||
t.equal(err.code, 'ENOENT', 'error code is unchanged') | ||
t.equal(err.message, 'could not get blob', 'error message is correctly delcared') | ||
t.end() | ||
}) | ||
) | ||
}) | ||
tape('error if requested size is incorrect', function (t) { | ||
@@ -52,0 +75,0 @@ pull( |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
31625
14
880
17
+ Addedpull-catch@^1.0.0
+ Addedpull-catch@1.1.0(transitive)