Comparing version 1.11.1 to 1.12.0
15
index.js
@@ -89,2 +89,6 @@ var cont = require('cont') | ||
function isEmptyHash(hash) { | ||
return empty === hash | ||
} | ||
dir = config.dir | ||
@@ -117,3 +121,3 @@ | ||
return function (cb) { | ||
if(hash === empty) return cb(null, true) | ||
if(isEmptyHash(hash)) return cb(null, true) | ||
var p = toPath(dir, hash) | ||
@@ -129,3 +133,3 @@ if(!p) return cb(new Error('not a valid blob hash:'+hash)) | ||
return function (cb) { | ||
if(hash === empty) return cb(null, 0) | ||
if(isEmptyHash(hash)) return cb(null, 0) | ||
var p = toPath(dir, hash) | ||
@@ -140,2 +144,3 @@ if(!p) return cb(new Error('not a valid blob hash:'+hash)) | ||
var meta = function (hash, cb) { | ||
if(isEmptyHash(hash)) return cb(null, {id: hash, size: 0, ts: 0}) | ||
stat(toPath(dir, hash), function (err, stat) { | ||
@@ -174,3 +179,3 @@ cb(err, toMeta(hash, stat)) | ||
function getSlice(opts) { | ||
if(opts.hash === empty) return pull.empty() | ||
if(isEmptyHash(opts.hash)) return pull.empty() | ||
@@ -208,3 +213,3 @@ var stream = defer.source() | ||
if(isHash(opts)) { | ||
if(opts === empty) return pull.empty() | ||
if(isEmptyHash(hash)) return pull.empty() | ||
return Read(toPath(dir, opts)) | ||
@@ -220,2 +225,3 @@ } | ||
}, | ||
isEmptyHash: isEmptyHash, | ||
@@ -327,1 +333,2 @@ getSlice: function (opts) { | ||
{ | ||
"name": "multiblob", | ||
"description": "", | ||
"version": "1.11.1", | ||
"version": "1.12.0", | ||
"homepage": "https://github.com/dominictarr/multiblob", | ||
@@ -6,0 +6,0 @@ "repository": { |
@@ -67,2 +67,8 @@ # multiblob | ||
### isEmptyHash(hash) | ||
Check if a given hash is actually the empty hash. If something has the empty hash, | ||
that is probably a bug. The above methods will act like the empty file is already in the store. | ||
## todo | ||
@@ -69,0 +75,0 @@ |
@@ -173,2 +173,3 @@ | ||
console.log(empty) | ||
t.ok(blobs.isEmptyHash(empty)) | ||
blobs.has(empty, function (err, has) { | ||
@@ -175,0 +176,0 @@ if(err) throw err |
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
29627
836
80