-
-
Notifications
You must be signed in to change notification settings - Fork 29
feat(read): change hasContent to return {sri, size} #88
Conversation
Some changes were needed to handle the changes of pickContentSri result, which is now `{sri, lstat}` instead of `sri`. Fixes #87
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So far so good! Thanks a bunch for this. I had a couple of nits, but also I'd like tests for the size functionality.
lib/content/read.js
Outdated
.catch({code: 'ENOENT'}, () => false) | ||
.catch({code: 'EPERM'}, err => { | ||
if (process.platform !== 'win32') { | ||
throw err | ||
} else { | ||
return false | ||
} | ||
}).then(sri => sri || false) | ||
}).then((content) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No parens around single-var fat-arrows
lib/content/read.js
Outdated
@@ -34,7 +35,8 @@ function readStream (cache, integrity, opts) { | |||
const stream = new PassThrough() | |||
pickContentSri( | |||
cache, integrity | |||
).then(sri => { | |||
).then((content) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No parens around single-var fat-arrows
lib/content/read.js
Outdated
@@ -13,7 +13,8 @@ BB.promisifyAll(fs) | |||
module.exports = read | |||
function read (cache, integrity, opts) { | |||
opts = opts || {} | |||
return pickContentSri(cache, integrity).then(sri => { | |||
return pickContentSri(cache, integrity).then((content) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No parens around single-var fat-arrows
lib/content/rm.js
Outdated
@@ -8,7 +8,8 @@ const rimraf = BB.promisify(require('rimraf')) | |||
|
|||
module.exports = rm | |||
function rm (cache, integrity) { | |||
return hasContent(cache, integrity).then(sri => { | |||
return hasContent(cache, integrity).then((content) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No parens around single-var fat-arrows
@@ -52,34 +54,33 @@ function readStream (cache, integrity, opts) { | |||
module.exports.hasContent = hasContent | |||
function hasContent (cache, integrity) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/zkat/cacache/blob/latest/test/content.read.js#L135-L148 will need to be updated
lib/content/read.js
Outdated
}).then(sri => sri || false) | ||
}).then((content) => { | ||
if (!content.sri) return false | ||
return ({ sri: content.sri, size: content.stat.size || 0 }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably don't need this || 0
anymore!
Changed the bits you adressed and tried to make a test that makes sense, if I can somehow make it better, just tell me :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wonderful. Thank you!
Some changes were needed to handle the changes of pickContentSri result,
which is now
{sri, lstat}
instead ofsri
.Fixes #87