cacache 17.1.0 → 17.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/content/write.js +23 -9
- package/package.json +3 -3
package/lib/content/write.js
CHANGED
|
@@ -15,6 +15,9 @@ const fsm = require('fs-minipass')
|
|
|
15
15
|
|
|
16
16
|
module.exports = write
|
|
17
17
|
|
|
18
|
+
// Cache of move operations in process so we don't duplicate
|
|
19
|
+
const moveOperations = new Map()
|
|
20
|
+
|
|
18
21
|
async function write (cache, data, opts = {}) {
|
|
19
22
|
const { algorithms, size, integrity } = opts
|
|
20
23
|
|
|
@@ -159,16 +162,27 @@ async function makeTmp (cache, opts) {
|
|
|
159
162
|
async function moveToDestination (tmp, cache, sri, opts) {
|
|
160
163
|
const destination = contentPath(cache, sri)
|
|
161
164
|
const destDir = path.dirname(destination)
|
|
162
|
-
|
|
163
|
-
|
|
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)
|
|
171
167
|
}
|
|
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)
|
|
172
186
|
}
|
|
173
187
|
|
|
174
188
|
function sizeError (expected, found) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cacache",
|
|
3
|
-
"version": "17.1.
|
|
3
|
+
"version": "17.1.2",
|
|
4
4
|
"cache-version": {
|
|
5
5
|
"content": "2",
|
|
6
6
|
"index": "5"
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"@npmcli/eslint-config": "^4.0.0",
|
|
63
|
-
"@npmcli/template-oss": "4.
|
|
63
|
+
"@npmcli/template-oss": "4.15.1",
|
|
64
64
|
"tap": "^16.0.0"
|
|
65
65
|
},
|
|
66
66
|
"engines": {
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"templateOSS": {
|
|
70
70
|
"//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
|
|
71
71
|
"windowsCI": false,
|
|
72
|
-
"version": "4.
|
|
72
|
+
"version": "4.15.1",
|
|
73
73
|
"publish": "true"
|
|
74
74
|
},
|
|
75
75
|
"author": "GitHub Inc.",
|