Ensure mktemp cleans up after itself
Ignore interrupts.
This commit is contained in:
parent
336c4d1b05
commit
d89b3272f4
@ -14,16 +14,11 @@ module FileUtils extend self
|
|||||||
# /tmp volume to the other volume. So we let the user override the tmp
|
# /tmp volume to the other volume. So we let the user override the tmp
|
||||||
# prefix if they need to.
|
# prefix if they need to.
|
||||||
tmp_prefix = ENV['HOMEBREW_TEMP'] || '/tmp'
|
tmp_prefix = ENV['HOMEBREW_TEMP'] || '/tmp'
|
||||||
tmp=Pathname.new `/usr/bin/mktemp -d #{tmp_prefix}/homebrew-#{name}-#{version}-XXXX`.strip
|
tmp = Pathname.new(`/usr/bin/mktemp -d #{tmp_prefix}/homebrew-#{name}-#{version}-XXXX`.chomp)
|
||||||
raise "Couldn't create build sandbox" if not tmp.directory? or $? != 0
|
raise "Failed to create sandbox: #{tmp}" unless tmp.directory?
|
||||||
begin
|
cd(tmp){ yield }
|
||||||
wd=Dir.pwd
|
ensure
|
||||||
chdir tmp
|
ignore_interrupts{ tmp.rmtree } if tmp
|
||||||
yield
|
|
||||||
ensure
|
|
||||||
chdir wd
|
|
||||||
tmp.rmtree
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# A version of mkdir that also changes to that folder in a block.
|
# A version of mkdir that also changes to that folder in a block.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user