Pass the mktemp prefix as an argument

This commit is contained in:
Jack Nagel 2013-10-02 22:01:09 -05:00
parent 02a0e4e2e0
commit b35d9906e5
2 changed files with 2 additions and 10 deletions

View File

@ -5,15 +5,7 @@ module FileUtils extend self
# Create a temporary directory then yield. When the block returns,
# recursively delete the temporary directory.
def mktemp
# Prefer download_name if it is defined, for two reasons:
# - The name attribute may be nil for resources that represent primary
# formula downloads, in which case we want to use just the owner name.
# - For resources that have a name defined, we want to use "owner--name"
# instead of just "name"
prefix = download_name if respond_to?(:download_name)
prefix ||= name
def mktemp(prefix=name)
# I used /tmp rather than `mktemp -td` because that generates a directory
# name with exotic characters like + in it, and these break badly written
# scripts that don't escape strings before trying to regexp them :(

View File

@ -50,7 +50,7 @@ class Resource
def stage(target=nil)
fetched = fetch
verify_download_integrity(fetched) if fetched.respond_to?(:file?) and fetched.file?
mktemp do
mktemp(download_name) do
downloader.stage
if block_given?
yield self