From 8a78c6fc400e9b9ca4068c61c8374a86dec7f2d1 Mon Sep 17 00:00:00 2001 From: nlf Date: Wed, 8 Mar 2023 09:34:29 -0800 Subject: [PATCH] fix: only add directories we made to _sparseTreeRoots (#6222) --- workspaces/arborist/lib/arborist/reify.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/workspaces/arborist/lib/arborist/reify.js b/workspaces/arborist/lib/arborist/reify.js index 87993cca876d6..760fa977ecfd9 100644 --- a/workspaces/arborist/lib/arborist/reify.js +++ b/workspaces/arborist/lib/arborist/reify.js @@ -535,9 +535,14 @@ module.exports = cls => class Reifier extends cls { await this[_renamePath](d, retired) } } - const made = await mkdir(node.path, { recursive: true }) this[_sparseTreeDirs].add(node.path) - this[_sparseTreeRoots].add(made) + const made = await mkdir(node.path, { recursive: true }) + // if the directory already exists, made will be undefined. if that's the case + // we don't want to remove it because we aren't the ones who created it so we + // omit it from the _sparseTreeRoots + if (made) { + this[_sparseTreeRoots].add(made) + } })) .then(() => process.emit('timeEnd', 'reify:createSparse')) }