Comparing version 17.0.7 to 17.1.0
@@ -20,5 +20,2 @@ 'use strict' | ||
const { algorithms, size, integrity } = opts | ||
if (algorithms && algorithms.length > 1) { | ||
throw new Error('opts.algorithms only supports a single algorithm for now') | ||
} | ||
@@ -34,12 +31,15 @@ if (typeof size === 'number' && data.length !== size) { | ||
const tmp = await makeTmp(cache, opts) | ||
try { | ||
await fs.writeFile(tmp.target, data, { flag: 'wx' }) | ||
await moveToDestination(tmp, cache, sri, opts) | ||
return { integrity: sri, size: data.length } | ||
} finally { | ||
if (!tmp.moved) { | ||
await fs.rm(tmp.target, { recursive: true, force: true }) | ||
for (const algo in sri) { | ||
const tmp = await makeTmp(cache, opts) | ||
const hash = sri[algo].toString() | ||
try { | ||
await fs.writeFile(tmp.target, data, { flag: 'wx' }) | ||
await moveToDestination(tmp, cache, hash, opts) | ||
} finally { | ||
if (!tmp.moved) { | ||
await fs.rm(tmp.target, { recursive: true, force: true }) | ||
} | ||
} | ||
} | ||
return { integrity: sri, size: data.length } | ||
} | ||
@@ -46,0 +46,0 @@ |
@@ -112,3 +112,3 @@ 'use strict' | ||
async function insert (cache, key, integrity, opts = {}) { | ||
const { metadata, size } = opts | ||
const { metadata, size, time } = opts | ||
const bucket = bucketPath(cache, key) | ||
@@ -118,3 +118,3 @@ const entry = { | ||
integrity: integrity && ssri.stringify(integrity), | ||
time: Date.now(), | ||
time: time || Date.now(), | ||
size, | ||
@@ -121,0 +121,0 @@ metadata, |
@@ -103,3 +103,7 @@ 'use strict' | ||
liveContent.add(entry.integrity.toString()) | ||
// integrity is stringified, re-parse it so we can get each hash | ||
const integrity = ssri.parse(entry.integrity) | ||
for (const algo in integrity) { | ||
liveContent.add(integrity[algo].toString()) | ||
} | ||
}) | ||
@@ -224,2 +228,3 @@ await new Promise((resolve, reject) => { | ||
size: entry.size, | ||
time: entry.time, | ||
}) | ||
@@ -226,0 +231,0 @@ stats.totalEntries++ |
{ | ||
"name": "cacache", | ||
"version": "17.0.7", | ||
"version": "17.1.0", | ||
"cache-version": { | ||
@@ -5,0 +5,0 @@ "content": "2", |
@@ -104,3 +104,3 @@ # cacache [![npm version](https://img.shields.io/npm/v/cacache.svg)](https://npm.im/cacache) [![license](https://img.shields.io/npm/l/cacache.svg)](https://npm.im/cacache) [![Travis](https://img.shields.io/travis/npm/cacache.svg)](https://travis-ci.org/npm/cacache) [![AppVeyor](https://ci.appveyor.com/api/projects/status/github/npm/cacache?svg=true)](https://ci.appveyor.com/project/npm/cacache) [![Coverage Status](https://coveralls.io/repos/github/npm/cacache/badge.svg?branch=latest)](https://coveralls.io/github/npm/cacache?branch=latest) | ||
The cacache team enthusiastically welcomes contributions and project participation! There's a bunch of things you can do if you want to contribute! The [Contributor Guide](CONTRIBUTING.md) has all the information you need for everything from reporting bugs to contributing entire new features. Please don't hesitate to jump in if you'd like to, or even ask us questions if something isn't clear. | ||
The cacache team enthusiastically welcomes contributions and project participation! There's a bunch of things you can do if you want to contribute! Please don't hesitate to jump in if you'd like to, or even ask us questions if something isn't clear. | ||
@@ -107,0 +107,0 @@ All participants and maintainers in this project are expected to follow [Code of Conduct](CODE_OF_CONDUCT.md), and just generally be excellent to each other. |
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
63165
1231