Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Karrys <luke@lukekarrys.com>2022-10-18 02:07:10 +0300
committerLuke Karrys <luke@lukekarrys.com>2022-10-19 00:12:42 +0300
commitaa010722996ef6de46e1bb937c6f8a94dc2844fa (patch)
treedfd845c3f845ff829dac29f31aed065e883bba2e /node_modules/cacache/lib/verify.js
parent38dc7f62dcee948bd834ddf59a9c24692bc98d90 (diff)
deps: update the following dependencies
- @npmcli/config@6.0.1 - @npmcli/disparity-colors@3.0.0 - @npmcli/git@4.0.1 - @npmcli/installed-package-contents@2.0.0 - @npmcli/map-workspaces@3.0.0 - @npmcli/metavuln-calculator@5.0.0 - @npmcli/move-file@3.0.0 - @npmcli/node-gyp@3.0.0 - @npmcli/package-json@3.0.0 - @npmcli/promise-spawn@4.0.0 - @npmcli/query@3.0.0 - @npmcli/run-script@5.0.0 - bin-links@4.0.1 - cacache@17.0.1 - ignore-walk@6.0.0 - init-package-json@4.0.1 - json-parse-even-better-errors@3.0.0 - make-fetch-happen@11.0.1 - normalize-package-data@5.0.0 - npm-audit-report@4.0.0 - npm-install-checks@6.0.0 - npm-packlist@7.0.1 - npm-pick-manifest@8.0.1 - npm-profile@7.0.1 - npm-registry-fetch@14.0.2 - npmlog@7.0.0 - pacote@15.0.1 - parse-conflict-json@3.0.0 - proc-log@3.0.0 - read-package-json-fast@3.0.1 - read-package-json@6.0.0 - ssri@10.0.0 - treeverse@3.0.0 - validate-npm-package-name@5.0.0 - write-file-atomic@5.0.0 Removed dependencies: - `@npmcli/fs`
Diffstat (limited to 'node_modules/cacache/lib/verify.js')
-rw-r--r--node_modules/cacache/lib/verify.js49
1 files changed, 22 insertions, 27 deletions
diff --git a/node_modules/cacache/lib/verify.js b/node_modules/cacache/lib/verify.js
index 52692a01d..33f566c12 100644
--- a/node_modules/cacache/lib/verify.js
+++ b/node_modules/cacache/lib/verify.js
@@ -1,20 +1,21 @@
'use strict'
-const util = require('util')
-
+const {
+ mkdir,
+ readFile,
+ rm,
+ stat,
+ truncate,
+ writeFile,
+} = require('fs/promises')
const pMap = require('p-map')
const contentPath = require('./content/path')
-const fixOwner = require('./util/fix-owner')
-const fs = require('@npmcli/fs')
const fsm = require('fs-minipass')
-const glob = util.promisify(require('glob'))
+const glob = require('./util/glob.js')
const index = require('./entry-index')
const path = require('path')
-const rimraf = util.promisify(require('rimraf'))
const ssri = require('ssri')
-const globify = pattern => pattern.split('\\').join('/')
-
const hasOwnProperty = (obj, key) =>
Object.prototype.hasOwnProperty.call(obj, key)
@@ -77,9 +78,7 @@ async function markEndTime (cache, opts) {
async function fixPerms (cache, opts) {
opts.log.silly('verify', 'fixing cache permissions')
- await fixOwner.mkdirfix(cache, cache)
- // TODO - fix file permissions too
- await fixOwner.chownr(cache, cache)
+ await mkdir(cache, { recursive: true })
return null
}
@@ -90,7 +89,7 @@ async function fixPerms (cache, opts) {
// 2. Mark each integrity value as "live"
// 3. Read entire filesystem tree in `content-vX/` dir
// 4. If content is live, verify its checksum and delete it if it fails
-// 5. If content is not marked as live, rimraf it.
+// 5. If content is not marked as live, rm it.
//
async function garbageCollect (cache, opts) {
opts.log.silly('verify', 'garbage collecting content')
@@ -107,7 +106,7 @@ async function garbageCollect (cache, opts) {
indexStream.on('end', resolve).on('error', reject)
})
const contentDir = contentPath.contentDir(cache)
- const files = await glob(globify(path.join(contentDir, '**')), {
+ const files = await glob(path.join(contentDir, '**'), {
follow: false,
nodir: true,
nosort: true,
@@ -139,8 +138,8 @@ async function garbageCollect (cache, opts) {
} else {
// No entries refer to this content. We can delete.
stats.reclaimedCount++
- const s = await fs.stat(f)
- await rimraf(f)
+ const s = await stat(f)
+ await rm(f, { recursive: true, force: true })
stats.reclaimedSize += s.size
}
return stats
@@ -153,7 +152,7 @@ async function garbageCollect (cache, opts) {
async function verifyContent (filepath, sri) {
const contentInfo = {}
try {
- const { size } = await fs.stat(filepath)
+ const { size } = await stat(filepath)
contentInfo.size = size
contentInfo.valid = true
await ssri.checkStream(new fsm.ReadStream(filepath), sri)
@@ -165,7 +164,7 @@ async function verifyContent (filepath, sri) {
throw err
}
- await rimraf(filepath)
+ await rm(filepath, { recursive: true, force: true })
contentInfo.valid = false
}
return contentInfo
@@ -211,13 +210,13 @@ async function rebuildIndex (cache, opts) {
}
async function rebuildBucket (cache, bucket, stats, opts) {
- await fs.truncate(bucket._path)
+ await truncate(bucket._path)
// This needs to be serialized because cacache explicitly
// lets very racy bucket conflicts clobber each other.
for (const entry of bucket) {
const content = contentPath(cache, entry.integrity)
try {
- await fs.stat(content)
+ await stat(content)
await index.insert(cache, entry.key, entry.integrity, {
metadata: entry.metadata,
size: entry.size,
@@ -236,22 +235,18 @@ async function rebuildBucket (cache, bucket, stats, opts) {
function cleanTmp (cache, opts) {
opts.log.silly('verify', 'cleaning tmp directory')
- return rimraf(path.join(cache, 'tmp'))
+ return rm(path.join(cache, 'tmp'), { recursive: true, force: true })
}
-function writeVerifile (cache, opts) {
+async function writeVerifile (cache, opts) {
const verifile = path.join(cache, '_lastverified')
opts.log.silly('verify', 'writing verifile to ' + verifile)
- try {
- return fs.writeFile(verifile, `${Date.now()}`)
- } finally {
- fixOwner.chownr.sync(cache, verifile)
- }
+ return writeFile(verifile, `${Date.now()}`)
}
module.exports.lastRun = lastRun
async function lastRun (cache) {
- const data = await fs.readFile(path.join(cache, '_lastverified'), { encoding: 'utf8' })
+ const data = await readFile(path.join(cache, '_lastverified'), { encoding: 'utf8' })
return new Date(+data)
}