Pass the mktemp prefix as an argument
This commit is contained in:
parent
02a0e4e2e0
commit
b35d9906e5
@ -5,15 +5,7 @@ module FileUtils extend self
|
|||||||
|
|
||||||
# Create a temporary directory then yield. When the block returns,
|
# Create a temporary directory then yield. When the block returns,
|
||||||
# recursively delete the temporary directory.
|
# recursively delete the temporary directory.
|
||||||
def mktemp
|
def mktemp(prefix=name)
|
||||||
# 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
|
|
||||||
|
|
||||||
# I used /tmp rather than `mktemp -td` because that generates a directory
|
# I used /tmp rather than `mktemp -td` because that generates a directory
|
||||||
# name with exotic characters like + in it, and these break badly written
|
# name with exotic characters like + in it, and these break badly written
|
||||||
# scripts that don't escape strings before trying to regexp them :(
|
# scripts that don't escape strings before trying to regexp them :(
|
||||||
|
|||||||
@ -50,7 +50,7 @@ class Resource
|
|||||||
def stage(target=nil)
|
def stage(target=nil)
|
||||||
fetched = fetch
|
fetched = fetch
|
||||||
verify_download_integrity(fetched) if fetched.respond_to?(:file?) and fetched.file?
|
verify_download_integrity(fetched) if fetched.respond_to?(:file?) and fetched.file?
|
||||||
mktemp do
|
mktemp(download_name) do
|
||||||
downloader.stage
|
downloader.stage
|
||||||
if block_given?
|
if block_given?
|
||||||
yield self
|
yield self
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user