Clean up cask audit tmpdir after use #17358
Merged
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.
brew style
with your changes locally?brew typecheck
with your changes locally?brew tests
with your changes locally?Cask::Audit#extract_artifacts
is used in the#audit_signing
and#cask_plist_min_os
methods to create a directory in/tmp
and extract cask artifacts without duplicating the work if it's already done. However, due to how this is set up,tmpdir
isn't removed afterward and the extracted artifacts will take up disk space until thetmp
directory is cleaned up. As a result, runningbrew audit --strict --online
locally can chew through disk space and it may not be clear to the user where their free space has gone.This adds a finalizer method to
Cask::Audit
to remove the created@tmpdir
(if any) once it's no longer needed. There may be a better way of addressing the issue but this works for now without having to restructure how these audits work.As discussed on Slack, it probably makes sense for
brew cleanup
to also clean uptmp
directories thatbrew
has created. From a quick glance at our use of#mktmpdir
, we would probably have to institute a common prefix (e.g., usinghomebrew-
orhomebrew-brew-
before existing prefixes) to be able to reasonably identifybrew
-createdtmp
directories (without manually maintaining a list of prefixes in use). There may be a better way of going about it but that was my initial thought.That said, it may not be necessary if everything's working correctly. With this patch in place, I've only ended up with a lingering
homebrew-unpack
tmp
directory on maybe one or two occasions but I haven't figured out why that happened (my best guess is that I may have prematurely interrupted a command using ^C).