Skip to content

fix: rmdir a stale directory before reaching for unmount - #33

Merged
uhs-robert merged 1 commit into
mainfrom
fix/31-cleanup-stale
Sep 11, 2026
Merged

uhs-robert merged 1 commit into
mainfrom
fix/31-cleanup-stale

Conversation

@uhs-robert

Copy link
Copy Markdown
Owner

Closes #31.

cleanup_stale runs on every setup() and called MountPoint.unmount on each empty leftover directory immediately after confirming it was not active, so every one walked fusermount, fusermount3, umount and diskutil for something that was never mounted. It now tries a plain rmdir and only escalates if that fails, which is the case the unmount was presumably guarding.

Second bug in the same three lines: local success = pcall(vim.fn.delete, ...) is true whenever the call did not raise, including when delete returns -1, so the count included failures. unmount also removes the directory itself, which made a naive fix undercount instead. Counting what is actually gone handles both.

The function had no test coverage, which is how both survived.

The startup sweep unmounted every empty leftover it found, right after
establishing it was not mounted, so each one walked the whole escalation.
The removal count was also taken from pcall rather than from the result.

Closes #31
@uhs-robert
uhs-robert merged commit 32107af into main Sep 11, 2026
3 checks passed
@uhs-robert
uhs-robert deleted the fix/31-cleanup-stale branch September 11, 2026 02:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cleanup_stale unmounts directories it just found unmounted

1 participant