Clean up cask audit tmpdir after use
`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 the `tmp` directory is cleaned up. As a result, running `brew 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.
This commit is contained in:
parent
ea5023a4ad
commit
5701f92321
@ -47,6 +47,12 @@ module Cask
|
||||
@token_conflicts = token_conflicts
|
||||
@only = only || []
|
||||
@except = except || []
|
||||
|
||||
# Clean up `#extract_artifacts` tmp dir when Audit object is destroyed
|
||||
ObjectSpace.define_finalizer(
|
||||
self,
|
||||
proc { FileUtils.remove_entry(@tmpdir) if @tmpdir },
|
||||
)
|
||||
end
|
||||
|
||||
def run!
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user