cacache 17.1.0 → 17.1.1
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 +14 -3
- 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,15 +162,23 @@ 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
|
-
|
|
165
|
+
if (moveOperations.has(destination)) {
|
|
166
|
+
return moveOperations.get(destination)
|
|
167
|
+
}
|
|
168
|
+
moveOperations.set(
|
|
169
|
+
destination,
|
|
170
|
+
fs.mkdir(destDir, { recursive: true })
|
|
171
|
+
.then(() => moveFile(tmp.target, destination, { overwrite: false }))
|
|
172
|
+
)
|
|
164
173
|
try {
|
|
165
|
-
await
|
|
174
|
+
await moveOperations.get(destination)
|
|
166
175
|
tmp.moved = true
|
|
167
176
|
} catch (err) {
|
|
168
177
|
if (!err.message.startsWith('The destination file exists')) {
|
|
169
178
|
throw Object.assign(err, { code: 'EEXIST' })
|
|
170
179
|
}
|
|
180
|
+
} finally {
|
|
181
|
+
moveOperations.delete(destination)
|
|
171
182
|
}
|
|
172
183
|
}
|
|
173
184
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cacache",
|
|
3
|
-
"version": "17.1.
|
|
3
|
+
"version": "17.1.1",
|
|
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.",
|