Skip to content

Commit

Permalink
fix: prevent circular mounts from infinite looping
Browse files Browse the repository at this point in the history
Co-authored-by: Jacob Gillespie <[email protected]>
  • Loading branch information
goller and jacobwgillespie authored May 15, 2024
1 parent 9c3d942 commit 9196367
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/utils/mounts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string>()) {
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)
Expand Down

0 comments on commit 9196367

Please sign in to comment.