From 9196367aff5585630e8df428ed451addc830d16b Mon Sep 17 00:00:00 2001 From: Chris Goller Date: Wed, 15 May 2024 10:53:52 -0500 Subject: [PATCH] fix: prevent circular mounts from infinite looping Co-authored-by: Jacob Gillespie --- src/utils/mounts.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/utils/mounts.ts b/src/utils/mounts.ts index 6d70969..24fbed5 100644 --- a/src/utils/mounts.ts +++ b/src/utils/mounts.ts @@ -117,9 +117,12 @@ async function mountDevice( } // Unmounts device at path. If the device is not mounted, this is a no-op. -export async function unmountDevice(path: string) { +export async function unmountDevice(path: string, seenPaths = new Set()) { + if (seenPaths.has(path)) return + seenPaths.add(path) + // Sometimes overlays are left over and need to be unmounted first. - const overlays = await findOverlayPaths(path) + const overlays = await findOverlayPaths(path, seenPaths) for (const overlay of overlays) { console.log(`Unmounting overlay ${overlay}`) await unmountDevice(overlay)