Skip to content

Commit afc38a5

Browse files
committedMay 17, 2023
deps: cacache@17.1.2
1 parent afb936c commit afc38a5

File tree

4 files changed

+31
-17
lines changed

4 files changed

+31
-17
lines changed
 

‎node_modules/cacache/lib/content/write.js

+23-9
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ const fsm = require('fs-minipass')
1515

1616
module.exports = write
1717

18+
// Cache of move operations in process so we don't duplicate
19+
const moveOperations = new Map()
20+
1821
async function write (cache, data, opts = {}) {
1922
const { algorithms, size, integrity } = opts
2023

@@ -159,16 +162,27 @@ async function makeTmp (cache, opts) {
159162
async function moveToDestination (tmp, cache, sri, opts) {
160163
const destination = contentPath(cache, sri)
161164
const destDir = path.dirname(destination)
162-
163-
await fs.mkdir(destDir, { recursive: true })
164-
try {
165-
await moveFile(tmp.target, destination, { overwrite: false })
166-
tmp.moved = true
167-
} catch (err) {
168-
if (!err.message.startsWith('The destination file exists')) {
169-
throw Object.assign(err, { code: 'EEXIST' })
170-
}
165+
if (moveOperations.has(destination)) {
166+
return moveOperations.get(destination)
171167
}
168+
moveOperations.set(
169+
destination,
170+
fs.mkdir(destDir, { recursive: true })
171+
.then(async () => {
172+
await moveFile(tmp.target, destination, { overwrite: false })
173+
tmp.moved = true
174+
return tmp.moved
175+
})
176+
.catch(err => {
177+
if (!err.message.startsWith('The destination file exists')) {
178+
throw Object.assign(err, { code: 'EEXIST' })
179+
}
180+
}).finally(() => {
181+
moveOperations.delete(destination)
182+
})
183+
184+
)
185+
return moveOperations.get(destination)
172186
}
173187

174188
function sizeError (expected, found) {

‎node_modules/cacache/package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cacache",
3-
"version": "17.1.0",
3+
"version": "17.1.2",
44
"cache-version": {
55
"content": "2",
66
"index": "5"
@@ -60,7 +60,7 @@
6060
},
6161
"devDependencies": {
6262
"@npmcli/eslint-config": "^4.0.0",
63-
"@npmcli/template-oss": "4.14.1",
63+
"@npmcli/template-oss": "4.15.1",
6464
"tap": "^16.0.0"
6565
},
6666
"engines": {
@@ -69,7 +69,7 @@
6969
"templateOSS": {
7070
"//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
7171
"windowsCI": false,
72-
"version": "4.14.1",
72+
"version": "4.15.1",
7373
"publish": "true"
7474
},
7575
"author": "GitHub Inc.",

‎package-lock.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191
"@npmcli/run-script": "^6.0.2",
9292
"abbrev": "^2.0.0",
9393
"archy": "~1.0.0",
94-
"cacache": "^17.1.0",
94+
"cacache": "^17.1.2",
9595
"chalk": "^4.1.2",
9696
"ci-info": "^3.8.0",
9797
"cli-columns": "^4.0.0",
@@ -3288,9 +3288,9 @@
32883288
}
32893289
},
32903290
"node_modules/cacache": {
3291-
"version": "17.1.0",
3292-
"resolved": "https://registry.npmjs.org/cacache/-/cacache-17.1.0.tgz",
3293-
"integrity": "sha512-hXpFU+Z3AfVmNuiLve1qxWHMq0RSIt5gjCKAHi/M6DktwFwDdAXAtunl1i4WSKaaVcU9IsRvXFg42jTHigcC6Q==",
3291+
"version": "17.1.2",
3292+
"resolved": "https://registry.npmjs.org/cacache/-/cacache-17.1.2.tgz",
3293+
"integrity": "sha512-VcRDUtZd9r7yfGDpdm3dBDBSQbLd19IqWs9q1tuB9g6kmxYLwIjfLngRKMCfDHxReuf0SBclRuYn66Xds7jzUQ==",
32943294
"inBundle": true,
32953295
"dependencies": {
32963296
"@npmcli/fs": "^3.1.0",

‎package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
"@npmcli/run-script": "^6.0.2",
6161
"abbrev": "^2.0.0",
6262
"archy": "~1.0.0",
63-
"cacache": "^17.1.0",
63+
"cacache": "^17.1.2",
6464
"chalk": "^4.1.2",
6565
"ci-info": "^3.8.0",
6666
"cli-columns": "^4.0.0",

0 commit comments

Comments
 (0)
Please sign in to comment.