cacache
Advanced tools
Comparing version 17.1.0 to 17.1.1
@@ -18,2 +18,5 @@ 'use strict' | ||
// Cache of move operations in process so we don't duplicate | ||
const moveOperations = new Map() | ||
async function write (cache, data, opts = {}) { | ||
@@ -163,6 +166,12 @@ const { algorithms, size, integrity } = opts | ||
const destDir = path.dirname(destination) | ||
await fs.mkdir(destDir, { recursive: true }) | ||
if (moveOperations.has(destination)) { | ||
return moveOperations.get(destination) | ||
} | ||
moveOperations.set( | ||
destination, | ||
fs.mkdir(destDir, { recursive: true }) | ||
.then(() => moveFile(tmp.target, destination, { overwrite: false })) | ||
) | ||
try { | ||
await moveFile(tmp.target, destination, { overwrite: false }) | ||
await moveOperations.get(destination) | ||
tmp.moved = true | ||
@@ -173,2 +182,4 @@ } catch (err) { | ||
} | ||
} finally { | ||
moveOperations.delete(destination) | ||
} | ||
@@ -175,0 +186,0 @@ } |
{ | ||
"name": "cacache", | ||
"version": "17.1.0", | ||
"version": "17.1.1", | ||
"cache-version": { | ||
@@ -63,3 +63,3 @@ "content": "2", | ||
"@npmcli/eslint-config": "^4.0.0", | ||
"@npmcli/template-oss": "4.14.1", | ||
"@npmcli/template-oss": "4.15.1", | ||
"tap": "^16.0.0" | ||
@@ -73,3 +73,3 @@ }, | ||
"windowsCI": false, | ||
"version": "4.14.1", | ||
"version": "4.15.1", | ||
"publish": "true" | ||
@@ -76,0 +76,0 @@ }, |
63490
1242