fix: never list live sockets or their runtime directories as reclaimable - #71
Open
iyashjayesh wants to merge 1 commit into
Open
fix: never list live sockets or their runtime directories as reclaimable#71iyashjayesh wants to merge 1 commit into
iyashjayesh wants to merge 1 commit into
Conversation
$TMPDIR (/var/folders/*/*/T) holds the runtime sockets of running processes. getDirectoryItems listed those directories as ordinary reclaimable items, so cleaning temp-files deleted them and broke the owning process. For podman this wiped $TMPDIR/podman, killing gvproxy and the API socket that /var/run/docker.sock points to. The docker category then failed in the same run with "Cannot connect to Podman", because the temp-files step had already deleted the socket it needed. Skip sockets and FIFOs, and skip directories that hold one. Sockets carry no reclaimable space, so no space is given up by leaving them alone.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Stops the cleaner from deleting the unix sockets of running processes.
$TMPDIRon macOS (/var/folders/*/*/T) is not just scratch files — it is where running processes keep their runtime sockets.getDirectoryItemslisted those directories as ordinary reclaimable items, so thetemp-filescategory deleted them and broke whatever owned them.I hit this with podman. A single
cleanrun wiped$TMPDIR/podman/, which killedgvproxyand the API socket that/var/run/docker.socksymlinks to. The VM process stayed alive, sopodman machine liststill reported "Currently running" while every connection was refused — a confusing state to debug. Podman Desktop separately reported "Docker socket is not disguised correctly", same cause. Recovery neededpodman machine stop && podman machine start.The failure is visible in the tool's own output, because
dockeris cleaned aftertemp-files:The scan phase saw a healthy podman and found 13.57 GB reclaimable; by the clean phase,
temp-fileshad deleted the socket thedockerstep needed. So this also fixes thedockercategory silently failing on podman setups.The fix skips sockets and FIFOs, and skips directories containing one (searched two levels deep — runtime directories keep sockets at or near the top). Sockets are 0 bytes, so no reclaimable space is given up.
Type of change
Related issue
None — found while running the tool.
Checklist
bun run lintpassesbun run testpasses (no regressions)bun run buildsucceedsNotes for reviewer
The guard lives in
getDirectoryItems, so it also covers thetrash,system-cache,system-logs,dev-cache,ios-backupsandmail-attachmentsscanners plus the interactive explorer. That is intentional — a live socket is never reclaimable space in any of those locations — but it is a wider blast radius thantemp-filesalone, so worth a look.Four tests added: a bare socket, a socket-holding directory, a nested socket, and a plain directory that must still be collected (guarding against over-exclusion).
Verified against a real
$TMPDIR(193 entries): 182 still listed, 11 live runtime directories now skipped,podmanno longer among them.macOS 15 (Darwin 25.5.0), arm64, bun 1.x, podman 5.6.2.