diff options
| author | Jack Nagel | 2013-08-13 16:13:23 -0500 |
|---|---|---|
| committer | Jack Nagel | 2013-08-13 16:43:51 -0500 |
| commit | d08508f7c79a711d83eba64ae43dc88e051eed56 (patch) | |
| tree | 840fa2f3a83c33cc7defb19cbf873351a2e08302 /Library | |
| parent | 22365f2f6d268113ed48a168389e7339df68c956 (diff) | |
| download | brew-d08508f7c79a711d83eba64ae43dc88e051eed56.tar.bz2 | |
Avoid reading whole files into memory during decompression
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/download_strategy.rb | 10 |
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 |
