aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJack Nagel2013-08-13 16:13:23 -0500
committerJack Nagel2013-08-13 16:43:51 -0500
commitd08508f7c79a711d83eba64ae43dc88e051eed56 (patch)
tree840fa2f3a83c33cc7defb19cbf873351a2e08302
parent22365f2f6d268113ed48a168389e7339df68c956 (diff)
downloadbrew-d08508f7c79a711d83eba64ae43dc88e051eed56.tar.bz2
Avoid reading whole files into memory during decompression
-rw-r--r--Library/Homebrew/download_strategy.rb10
1 files changed, 7 insertions, 3 deletions
diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb
index 90b6c92ae..9fc10ce17 100644
--- a/Library/Homebrew/download_strategy.rb
+++ b/Library/Homebrew/download_strategy.rb
@@ -107,9 +107,13 @@ class CurlDownloadStrategy < AbstractDownloadStrategy
# regardless of the current working directory; the only way to
# write elsewhere is to use the stdout
with_system_path do
- data = `gunzip -f "#{@tarball_path}" -c`
- File.open(File.basename(basename_without_params, '.gz'), 'w') do |f|
- f.write data
+ target = File.basename(basename_without_params, ".gz")
+
+ IO.popen("gunzip -f '#{@tarball_path}' -c") do |pipe|
+ File.open(target, "w") do |f|
+ buf = ""
+ f.write(buf) while pipe.read(1024, buf)
+ end
end
end
when :gzip, :bzip2, :compress, :tar