Socket
Socket
Sign inDemoInstall

cacache

Package Overview
Dependencies
56
Maintainers
3
Versions
100
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 10.0.4 to 11.0.0

20

CHANGELOG.md

@@ -5,2 +5,22 @@ # Change Log

<a name="11.0.0"></a>
# [11.0.0](https://github.com/zkat/cacache/compare/v10.0.4...v11.0.0) (2018-04-09)
### Features
* **opts:** use figgy-pudding for opts ([#128](https://github.com/zkat/cacache/issues/128)) ([33d4eed](https://github.com/zkat/cacache/commit/33d4eed))
### meta
* drop support for node@4 ([529f347](https://github.com/zkat/cacache/commit/529f347))
### BREAKING CHANGES
* node@4 is no longer supported
<a name="10.0.4"></a>

@@ -7,0 +27,0 @@ ## [10.0.4](https://github.com/zkat/cacache/compare/v10.0.3...v10.0.4) (2018-02-16)

36

get.js

@@ -5,2 +5,3 @@ 'use strict'

const figgyPudding = require('figgy-pudding')
const fs = require('fs')

@@ -14,2 +15,8 @@ const index = require('./lib/entry-index')

const GetOpts = figgyPudding({
integrity: {},
memoize: {},
size: {}
})
module.exports = function get (cache, key, opts) {

@@ -22,7 +29,7 @@ return getData(false, cache, key, opts)

function getData (byDigest, cache, key, opts) {
opts = opts || {}
opts = GetOpts(opts)
const memoized = (
byDigest
? memo.get.byDigest(cache, key, opts)
: memo.get(cache, key, opts)
? memo.get.byDigest(cache, key, opts)
: memo.get(cache, key, opts)
)

@@ -64,3 +71,3 @@ if (memoized && opts.memoize !== false) {

function getStream (cache, key, opts) {
opts = opts || {}
opts = GetOpts(opts)
let stream = through()

@@ -98,3 +105,2 @@ const memoized = memo.get(cache, key, opts)

}
opts.size = opts.size == null ? entry.size : opts.size
stream.emit('metadata', entry.metadata)

@@ -109,3 +115,5 @@ stream.emit('integrity', entry.integrity)

pipe(
read.readStream(cache, entry.integrity, opts),
read.readStream(cache, entry.integrity, opts.concat({
size: opts.size == null ? entry.size : opts.size
})),
memoStream,

@@ -120,3 +128,3 @@ stream

function getStreamDigest (cache, integrity, opts) {
opts = opts || {}
opts = GetOpts(opts)
const memoized = memo.get.byDigest(cache, integrity, opts)

@@ -153,3 +161,3 @@ if (memoized && opts.memoize !== false) {

function info (cache, key, opts) {
opts = opts || {}
opts = GetOpts(opts)
const memoized = memo.get(cache, key, opts)

@@ -172,3 +180,3 @@ if (memoized && opts.memoize !== false) {

function copy (byDigest, cache, key, dest, opts) {
opts = opts || {}
opts = GetOpts(opts)
if (read.copy) {

@@ -192,9 +200,9 @@ return (

return fs.writeFileAsync(dest, byDigest ? res : res.data)
.then(() => byDigest ? key : {
metadata: res.metadata,
size: res.size,
integrity: res.integrity
})
.then(() => byDigest ? key : {
metadata: res.metadata,
size: res.size,
integrity: res.integrity
})
})
}
}

@@ -6,2 +6,3 @@ 'use strict'

const contentPath = require('./path')
const figgyPudding = require('figgy-pudding')
const fs = require('graceful-fs')

@@ -15,5 +16,9 @@ const PassThrough = require('stream').PassThrough

const ReadOpts = figgyPudding({
size: {}
})
module.exports = read
function read (cache, integrity, opts) {
opts = opts || {}
opts = ReadOpts(opts)
return pickContentSri(cache, integrity).then(content => {

@@ -37,3 +42,3 @@ const sri = content.sri

function readStream (cache, integrity, opts) {
opts = opts || {}
opts = ReadOpts(opts)
const stream = new PassThrough()

@@ -62,3 +67,3 @@ pickContentSri(

function copy (cache, integrity, dest, opts) {
opts = opts || {}
opts = ReadOpts(opts)
return pickContentSri(cache, integrity).then(content => {

@@ -75,13 +80,13 @@ const sri = content.sri

return pickContentSri(cache, integrity)
.catch({code: 'ENOENT'}, () => false)
.catch({code: 'EPERM'}, err => {
if (process.platform !== 'win32') {
throw err
} else {
return false
}
}).then(content => {
if (!content.sri) return false
return ({ sri: content.sri, size: content.stat.size })
})
.catch({code: 'ENOENT'}, () => false)
.catch({code: 'EPERM'}, err => {
if (process.platform !== 'win32') {
throw err
} else {
return false
}
}).then(content => {
if (!content.sri) return false
return ({ sri: content.sri, size: content.stat.size })
})
}

@@ -103,12 +108,12 @@

}))
.catch(err => {
if ([].some.call(err, e => e.code === 'ENOENT')) {
throw Object.assign(
new Error('No matching content found for ' + sri.toString()),
{code: 'ENOENT'}
)
} else {
throw err[0]
}
})
.catch(err => {
if ([].some.call(err, e => e.code === 'ENOENT')) {
throw Object.assign(
new Error('No matching content found for ' + sri.toString()),
{code: 'ENOENT'}
)
} else {
throw err[0]
}
})
}

@@ -115,0 +120,0 @@ }

@@ -31,3 +31,5 @@ 'use strict'

}
const sri = ssri.fromData(data, opts)
const sri = ssri.fromData(data, {
algorithms: opts.algorithms
})
if (opts.integrity && !ssri.checkData(data, opts.integrity, opts)) {

@@ -34,0 +36,0 @@ return BB.reject(checksumError(opts.integrity, sri))

@@ -7,2 +7,3 @@ 'use strict'

const crypto = require('crypto')
const figgyPudding = require('figgy-pudding')
const fixOwner = require('./util/fix-owner')

@@ -33,5 +34,12 @@ const fs = require('graceful-fs')

const IndexOpts = figgyPudding({
metadata: {},
size: {},
uid: {},
gid: {}
})
module.exports.insert = insert
function insert (cache, key, integrity, opts) {
opts = opts || {}
opts = IndexOpts(opts)
const bucket = bucketPath(cache, key)

@@ -202,5 +210,5 @@ const entry = {

return crypto
.createHash(digest)
.update(str)
.digest('hex')
.createHash(digest)
.update(str)
.digest('hex')
}

@@ -223,4 +231,4 @@

return readdirAsync(dir)
.catch({code: 'ENOENT'}, () => [])
.catch({code: 'ENOTDIR'}, () => [])
.catch({code: 'ENOENT'}, () => [])
.catch({code: 'ENOTDIR'}, () => [])
}

@@ -227,0 +235,0 @@

@@ -5,2 +5,3 @@ 'use strict'

const figgyPudding = require('figgy-pudding')
const fixOwner = require('./fix-owner')

@@ -11,5 +12,11 @@ const path = require('path')

const TmpOpts = figgyPudding({
tmpPrefix: {},
uid: {},
gid: {}
})
module.exports.mkdir = mktmpdir
function mktmpdir (cache, opts) {
opts = opts || {}
opts = TmpOpts(opts)
const tmpTarget = uniqueFilename(path.join(cache, 'tmp'), opts.tmpPrefix)

@@ -27,3 +34,3 @@ return fixOwner.mkdirfix(tmpTarget, opts.uid, opts.gid).then(() => {

}
opts = opts || {}
opts = TmpOpts(opts)
return BB.using(mktmpdir(cache, opts).disposer(rimraf), cb)

@@ -34,3 +41,4 @@ }

function fixtmpdir (cache, opts) {
opts = TmpOpts(opts)
return fixOwner(path.join(cache, 'tmp'), opts.uid, opts.gid)
}

@@ -6,2 +6,3 @@ 'use strict'

const contentPath = require('./content/path')
const figgyPudding = require('figgy-pudding')
const finished = BB.promisify(require('mississippi').finished)

@@ -18,6 +19,18 @@ const fixOwner = require('./util/fix-owner')

const VerifyOpts = figgyPudding({
concurrency: {
default: 20
},
filter: {},
log: {
default: { silly () {} }
},
uid: {},
gid: {}
})
module.exports = verify
function verify (cache, opts) {
opts = opts || {}
opts.log && opts.log.silly('verify', 'verifying cache at', cache)
opts = VerifyOpts(opts)
opts.log.silly('verify', 'verifying cache at', cache)
return BB.reduce([

@@ -45,3 +58,3 @@ markStartTime,

stats.runTime.total = stats.endTime - stats.startTime
opts.log && opts.log.silly('verify', 'verification finished for', cache, 'in', `${stats.runTime.total}ms`)
opts.log.silly('verify', 'verification finished for', cache, 'in', `${stats.runTime.total}ms`)
})

@@ -59,3 +72,3 @@ }

function fixPerms (cache, opts) {
opts.log && opts.log.silly('verify', 'fixing cache permissions')
opts.log.silly('verify', 'fixing cache permissions')
return fixOwner.mkdirfix(cache, opts.uid, opts.gid).then(() => {

@@ -77,7 +90,7 @@ // TODO - fix file permissions too

function garbageCollect (cache, opts) {
opts.log && opts.log.silly('verify', 'garbage collecting content')
opts.log.silly('verify', 'garbage collecting content')
const indexStream = index.lsStream(cache)
const liveContent = new Set()
indexStream.on('data', entry => {
if (opts && opts.filter && !opts.filter(entry)) { return }
if (opts.filter && !opts.filter(entry)) { return }
liveContent.add(entry.integrity.toString())

@@ -125,3 +138,3 @@ })

}
}, {concurrency: opts.concurrency || 20}))
}, {concurrency: opts.concurrency}))
})

@@ -150,3 +163,3 @@ })

function rebuildIndex (cache, opts) {
opts.log && opts.log.silly('verify', 'rebuilding index')
opts.log.silly('verify', 'rebuilding index')
return index.ls(cache).then(entries => {

@@ -163,3 +176,3 @@ const stats = {

const entry = entries[k]
const excluded = opts && opts.filter && !opts.filter(entry)
const excluded = opts.filter && !opts.filter(entry)
excluded && stats.rejectedEntries++

@@ -181,3 +194,3 @@ if (buckets[hashed] && !excluded) {

return rebuildBucket(cache, buckets[key], stats, opts)
}, {concurrency: opts.concurrency || 20}).then(() => stats)
}, {concurrency: opts.concurrency}).then(() => stats)
})

@@ -207,3 +220,3 @@ }

function cleanTmp (cache, opts) {
opts.log && opts.log.silly('verify', 'cleaning tmp directory')
opts.log.silly('verify', 'cleaning tmp directory')
return rimraf(path.join(cache, 'tmp'))

@@ -214,3 +227,3 @@ }

const verifile = path.join(cache, '_lastverified')
opts.log && opts.log.silly('verify', 'writing verifile to ' + verifile)
opts.log.silly('verify', 'writing verifile to ' + verifile)
return fs.writeFileAsync(verifile, '' + (+(new Date())))

@@ -217,0 +230,0 @@ }

{
"name": "cacache",
"version": "10.0.4",
"version": "11.0.0",
"cache-version": {

@@ -21,3 +21,3 @@ "content": "2",

"release": "standard-version -s",
"test": "cross-env CACACHE_UPDATE_LOCALE_FILES=true nyc --all -- tap -J test/*.js",
"test": "cross-env CACACHE_UPDATE_LOCALE_FILES=true tap --coverage --nyc-arg=--all -J test/*.js",
"test-docker": "docker run -it --rm --name pacotest -v \"$PWD\":/tmp -w /tmp node:latest npm test",

@@ -64,6 +64,7 @@ "update-coc": "weallbehave -o . && git add CODE_OF_CONDUCT.md && git commit -m 'docs(coc): updated CODE_OF_CONDUCT.md'",

"chownr": "^1.0.1",
"figgy-pudding": "^3.1.0",
"glob": "^7.1.2",
"graceful-fs": "^4.1.11",
"lru-cache": "^4.1.1",
"mississippi": "^2.0.0",
"lru-cache": "^4.1.2",
"mississippi": "^3.0.0",
"mkdirp": "^0.5.1",

@@ -73,3 +74,3 @@ "move-concurrently": "^1.0.1",

"rimraf": "^2.6.2",
"ssri": "^5.2.4",
"ssri": "^5.3.0",
"unique-filename": "^1.1.0",

@@ -80,11 +81,10 @@ "y18n": "^4.0.0"

"benchmark": "^2.1.4",
"chalk": "^2.3.1",
"cross-env": "^5.1.3",
"nyc": "^11.4.1",
"chalk": "^2.3.2",
"cross-env": "^5.1.4",
"require-inject": "^1.4.2",
"safe-buffer": "^5.1.1",
"standard": "^10.0.3",
"standard": "^11.0.1",
"standard-version": "^4.3.0",
"tacks": "^1.2.2",
"tap": "^11.1.0",
"tap": "^11.1.3",
"weallbehave": "^1.2.0",

@@ -91,0 +91,0 @@ "weallcontribute": "^1.0.8"

'use strict'
const figgyPudding = require('figgy-pudding')
const index = require('./lib/entry-index')

@@ -8,9 +9,22 @@ const memo = require('./lib/memoization')

const PutOpts = figgyPudding({
algorithms: {
default: ['sha512']
},
integrity: {},
memoize: {},
metadata: {},
size: {},
tmpPrefix: {},
uid: {},
gid: {}
})
module.exports = putData
function putData (cache, key, data, opts) {
opts = opts || {}
opts = PutOpts(opts)
return write(cache, data, opts).then(res => {
// TODO - stop modifying opts
opts.size = res.size
return index.insert(cache, key, res.integrity, opts).then(entry => {
return index.insert(
cache, key, res.integrity, opts.concat({size: res.size})
).then(entry => {
if (opts.memoize) {

@@ -26,3 +40,3 @@ memo.put(cache, entry, data, opts)

function putStream (cache, key, opts) {
opts = opts || {}
opts = PutOpts(opts)
let integrity

@@ -50,5 +64,3 @@ let size

contentStream.end(() => {
// TODO - stop modifying `opts`
opts.size = size
index.insert(cache, key, integrity, opts).then(entry => {
index.insert(cache, key, integrity, opts.concat({size})).then(entry => {
if (opts.memoize) {

@@ -55,0 +67,0 @@ memo.put(cache, entry, Buffer.concat(memoData, memoTotal), opts)

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc