Merge pull request #17377 from samford/cask-audit-rework-tmpdir-removal

cask/audit: Rework tmpdir removal
This commit is contained in:
Mike McQuaid 2024-05-27 19:11:36 +01:00 committed by GitHub
commit 92adf6a0b7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -47,12 +47,6 @@ module Cask
@token_conflicts = token_conflicts @token_conflicts = token_conflicts
@only = only || [] @only = only || []
@except = except || [] @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 end
def run! def run!
@ -540,6 +534,12 @@ module Cask
@tmpdir ||= Pathname(Dir.mktmpdir("cask-audit", HOMEBREW_TEMP)) @tmpdir ||= Pathname(Dir.mktmpdir("cask-audit", HOMEBREW_TEMP))
# Clean up tmp dir when @tmpdir object is destroyed
ObjectSpace.define_finalizer(
@tmpdir,
proc { FileUtils.remove_entry(@tmpdir) },
)
ohai "Downloading and extracting artifacts" ohai "Downloading and extracting artifacts"
downloaded_path = download.fetch downloaded_path = download.fetch