Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: npm/cacache
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v16.1.0
Choose a base ref
...
head repository: npm/cacache
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v16.1.1
Choose a head ref
  • 4 commits
  • 11 files changed
  • 5 contributors

Commits on Jun 2, 2022

  1. fix(read): change lstat to stat to correctly evaluate file size (#114)

    * fix(read): change lstat to stat to support symlinks in the cache
    
    * fix(test/read): lstat -> stat
    yorickvP authored Jun 2, 2022

    Verified

    This commit was signed with the committer’s verified signature.
    wmouchere William Mouchère
    Copy the full SHA
    e3a2928 View commit details
  2. chore: Use non-legacy hash in test (#113)

    Especially since openssl 3 is out.
    `openssl list -digest-algorithms` to get a recent list of non
    kapouer authored Jun 2, 2022

    Verified

    This commit was signed with the committer’s verified signature.
    wmouchere William Mouchère
    Copy the full SHA
    07532fb View commit details
  3. chore: bump @npmcli/template-oss from 3.4.3 to 3.5.0 (#109)

    * chore: bump @npmcli/template-oss from 3.4.3 to 3.5.0
    
    Bumps [@npmcli/template-oss](https://github.com/npm/template-oss) from 3.4.3 to 3.5.0.
    - [Release notes](https://github.com/npm/template-oss/releases)
    - [Changelog](https://github.com/npm/template-oss/blob/main/CHANGELOG.md)
    - [Commits](npm/template-oss@v3.4.3...v3.5.0)
    
    ---
    updated-dependencies:
    - dependency-name: "@npmcli/template-oss"
      dependency-type: direct:development
      update-type: version-update:semver-minor
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    
    * chore: postinstall for dependabot template-oss PR
    
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    Co-authored-by: Gar <gar+gh@danger.computer>
    dependabot[bot] and wraithgar authored Jun 2, 2022
    Copy the full SHA
    121b9a2 View commit details
  4. chore(main): release 16.1.1 (#115)

    Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
    github-actions[bot] authored Jun 2, 2022
    Copy the full SHA
    e8d1e85 View commit details
4 changes: 2 additions & 2 deletions .github/workflows/audit.yml
Original file line number Diff line number Diff line change
@@ -15,8 +15,8 @@ jobs:
- uses: actions/checkout@v3
- name: Setup git user
run: |
git config --global user.email "ops+robot@npmjs.com"
git config --global user.name "npm team"
git config --global user.email "npm-cli+bot@github.com"
git config --global user.name "npm CLI robot"
- uses: actions/setup-node@v3
with:
node-version: 16.x
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -22,8 +22,8 @@ jobs:
- uses: actions/checkout@v3
- name: Setup git user
run: |
git config --global user.email "ops+robot@npmjs.com"
git config --global user.name "npm team"
git config --global user.email "npm-cli+bot@github.com"
git config --global user.name "npm CLI robot"
- uses: actions/setup-node@v3
with:
node-version: 16.x
@@ -57,8 +57,8 @@ jobs:
- uses: actions/checkout@v3
- name: Setup git user
run: |
git config --global user.email "ops+robot@npmjs.com"
git config --global user.name "npm team"
git config --global user.email "npm-cli+bot@github.com"
git config --global user.name "npm CLI robot"
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
4 changes: 2 additions & 2 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -34,8 +34,8 @@ jobs:
- uses: actions/checkout@v3
- name: Setup git user
run: |
git config --global user.email "ops+robot@npmjs.com"
git config --global user.name "npm team"
git config --global user.email "npm-cli+bot@github.com"
git config --global user.name "npm CLI robot"
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
4 changes: 2 additions & 2 deletions .github/workflows/post-dependabot.yml
Original file line number Diff line number Diff line change
@@ -16,8 +16,8 @@ jobs:
- uses: actions/checkout@v3
- name: Setup git user
run: |
git config --global user.email "ops+robot@npmjs.com"
git config --global user.name "npm team"
git config --global user.email "npm-cli+bot@github.com"
git config --global user.name "npm CLI robot"
- uses: actions/setup-node@v3
with:
node-version: 16.x
4 changes: 2 additions & 2 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
@@ -20,8 +20,8 @@ jobs:
fetch-depth: 0
- name: Setup git user
run: |
git config --global user.email "ops+robot@npmjs.com"
git config --global user.name "npm team"
git config --global user.email "npm-cli+bot@github.com"
git config --global user.name "npm CLI robot"
- uses: actions/setup-node@v3
with:
node-version: 16.x
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -19,6 +19,7 @@
!/.github/
!/.gitignore
!/.npmrc
!/CODE_OF_CONDUCT.md
!/SECURITY.md
!/bin/
!/lib/
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## [16.1.1](https://github.com/npm/cacache/compare/v16.1.0...v16.1.1) (2022-06-02)


### Bug Fixes

* **read:** change lstat to stat to correctly evaluate file size ([#114](https://github.com/npm/cacache/issues/114)) ([e3a2928](https://github.com/npm/cacache/commit/e3a2928e053e19fb6e8e73946ffe3d212e402ba7))

## [16.1.0](https://github.com/npm/cacache/compare/v16.0.7...v16.1.0) (2022-05-17)


7 changes: 7 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<!-- This file is automatically added by @npmcli/template-oss. Do not edit. -->

All interactions in this repo are covered by the [npm Code of
Conduct](https://docs.npmjs.com/policies/conduct)

The npm cli team may, at its own discretion, moderate, remove, or edit
any interactions such as pull requests, issues, and comments.
10 changes: 5 additions & 5 deletions lib/content/read.js
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@ async function read (cache, integrity, opts = {}) {
const { size } = opts
const { stat, cpath, sri } = await withContentSri(cache, integrity, async (cpath, sri) => {
// get size
const stat = await fs.lstat(cpath)
const stat = await fs.stat(cpath)
return { stat, cpath, sri }
})
if (typeof size === 'number' && stat.size !== size) {
@@ -73,8 +73,8 @@ function readStream (cache, integrity, opts = {}) {
// Set all this up to run on the stream and then just return the stream
Promise.resolve().then(async () => {
const { stat, cpath, sri } = await withContentSri(cache, integrity, async (cpath, sri) => {
// just lstat to ensure it exists
const stat = await fs.lstat(cpath)
// just stat to ensure it exists
const stat = await fs.stat(cpath)
return { stat, cpath, sri }
})
if (typeof size === 'number' && size !== stat.size) {
@@ -111,7 +111,7 @@ async function hasContent (cache, integrity) {

try {
return await withContentSri(cache, integrity, async (cpath, sri) => {
const stat = await fs.lstat(cpath)
const stat = await fs.stat(cpath)
return { size: stat.size, sri, stat }
})
} catch (err) {
@@ -139,7 +139,7 @@ function hasContentSync (cache, integrity) {

return withContentSriSync(cache, integrity, (cpath, sri) => {
try {
const stat = fs.lstatSync(cpath)
const stat = fs.statSync(cpath)
return { size: stat.size, sri, stat }
} catch (err) {
if (err.code === 'ENOENT') {
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cacache",
"version": "16.1.0",
"version": "16.1.1",
"cache-version": {
"content": "2",
"index": "5"
@@ -69,7 +69,7 @@
},
"devDependencies": {
"@npmcli/eslint-config": "^3.0.1",
"@npmcli/template-oss": "3.4.3",
"@npmcli/template-oss": "3.5.0",
"tap": "^16.0.0"
},
"engines": {
@@ -78,7 +78,7 @@
"templateOSS": {
"//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
"windowsCI": false,
"version": "3.4.3"
"version": "3.5.0"
},
"author": "GitHub Inc."
}
18 changes: 9 additions & 9 deletions test/content/read.js
Original file line number Diff line number Diff line change
@@ -17,12 +17,12 @@ permissionError.code = 'EPERM'

// helpers
const getRead = (t, opts) => t.mock('../../lib/content/read', opts)
const getReadLstatFailure = (t, err) => getRead(t, {
const getReadStatFailure = (t, err) => getRead(t, {
'@npmcli/fs': Object.assign({}, require('@npmcli/fs'), {
async lstat (path) {
async stat (path) {
throw err
},
lstatSync () {
statSync () {
throw err
},
}),
@@ -74,7 +74,7 @@ t.test('read.stream: returns a stream with cache content data', function (t) {

t.test('read: allows hashAlgorithm configuration', function (t) {
const CONTENT = Buffer.from('foobarbaz')
const HASH = 'whirlpool'
const HASH = 'sha384'
const INTEGRITY = ssri.fromData(CONTENT, { algorithms: [HASH] })
const CACHE = t.testdir(
CacheContent({
@@ -261,7 +261,7 @@ t.test('read: opening large files', function (t) {
const CACHE = t.testdir()
const mockedRead = getRead(t, {
'@npmcli/fs': Object.assign({}, require('@npmcli/fs'), {
async lstat (path) {
async stat (path) {
return { size: Number.MAX_SAFE_INTEGER }
},
}),
@@ -370,7 +370,7 @@ t.test('hasContent: tests content existence', (t) => {
t.test('hasContent: permission error', (t) => {
const CACHE = t.testdir()
// setup a syntetic permission error
const mockedRead = getReadLstatFailure(t, permissionError)
const mockedRead = getReadStatFailure(t, permissionError)

t.plan(1)
t.rejects(
@@ -382,7 +382,7 @@ t.test('hasContent: permission error', (t) => {

t.test('hasContent: generic error', (t) => {
const CACHE = t.testdir()
const mockedRead = getReadLstatFailure(t, genericError)
const mockedRead = getReadStatFailure(t, genericError)

t.plan(1)
t.resolves(
@@ -426,7 +426,7 @@ t.test('hasContent.sync: checks content existence synchronously', (t) => {

t.test('hasContent.sync: permission error', (t) => {
const CACHE = t.testdir()
const mockedRead = getReadLstatFailure(t, permissionError)
const mockedRead = getReadStatFailure(t, permissionError)

t.throws(
() => mockedRead.hasContent.sync(CACHE, 'sha1-deadbeef sha1-13371337'),
@@ -438,7 +438,7 @@ t.test('hasContent.sync: permission error', (t) => {

t.test('hasContent.sync: generic error', (t) => {
const CACHE = t.testdir()
const mockedRead = getReadLstatFailure(t, genericError)
const mockedRead = getReadStatFailure(t, genericError)

t.notOk(
mockedRead.hasContent.sync(CACHE, 'sha1-deadbeef sha1-13371337'),