From d08508f7c79a711d83eba64ae43dc88e051eed56 Mon Sep 17 00:00:00 2001 From: Jack Nagel Date: Tue, 13 Aug 2013 16:13:23 -0500 Subject: [PATCH] Avoid reading whole files into memory during decompression --- Library/Homebrew/download_strategy.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb index 90b6c92aee..9fc10ce171 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