summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThe Bundler Bot <bot@bundler.io>2018-01-19 17:44:46 +0000
committerThe Bundler Bot <bot@bundler.io>2018-01-19 17:44:46 +0000
commit596ae6b29f59d00f0bfb0d4519c32c11e4d15aaf (patch)
tree733ce82f413b44665818820a45778653b19d5e02
parentd2ff01867b5d4fcbbf6e6dae1ddcc155392909a3 (diff)
parent724894a4cea4b3f13d9c6a626ed2fdaab88f7474 (diff)
downloadbundler-596ae6b29f59d00f0bfb0d4519c32c11e4d15aaf.tar.gz
Auto merge of #6264 - bundler:colby/client-index-gzip-error, r=indirect
handle gzip corruption errors in the compact index client ### What was the end-user problem that led to this PR? Bundler will raise an exception and crash if the Gzip that the Compact Client Index downloaded was corrupt. ### What was your diagnosis of the problem? See #6261 ### What is your fix for the problem, implemented in this PR? Handle the exception and allow Bundler to continue without crashing
-rw-r--r--lib/bundler/compact_index_client/updater.rb2
-rw-r--r--spec/bundler/compact_index_client/updater_spec.rb23
2 files changed, 19 insertions, 6 deletions
diff --git a/lib/bundler/compact_index_client/updater.rb b/lib/bundler/compact_index_client/updater.rb
index 91ca653e8d..950306fee5 100644
--- a/lib/bundler/compact_index_client/updater.rb
+++ b/lib/bundler/compact_index_client/updater.rb
@@ -83,6 +83,8 @@ module Bundler
"Bundler does not have write access to create a temp directory " \
"within #{Dir.tmpdir}. Bundler must have write access to your " \
"systems temp directory to function properly. "
+ rescue Zlib::GzipFile::Error
+ raise Bundler::HTTPError
end
def etag_for(path)
diff --git a/spec/bundler/compact_index_client/updater_spec.rb b/spec/bundler/compact_index_client/updater_spec.rb
index af24e58d5f..fd554a7b0d 100644
--- a/spec/bundler/compact_index_client/updater_spec.rb
+++ b/spec/bundler/compact_index_client/updater_spec.rb
@@ -5,16 +5,16 @@ require "bundler/compact_index_client"
require "bundler/compact_index_client/updater"
RSpec.describe Bundler::CompactIndexClient::Updater do
- subject(:updater) { described_class.new(fetcher) }
-
let(:fetcher) { double(:fetcher) }
+ let(:local_path) { Pathname("/tmp/localpath") }
+ let(:remote_path) { double(:remote_path) }
+
+ subject(:updater) { described_class.new(fetcher) }
context "when the ETag header is missing" do
# Regression test for https://github.com/bundler/bundler/issues/5463
let(:response) { double(:response, :body => "") }
- let(:local_path) { Pathname("/tmp/localpath") }
- let(:remote_path) { double(:remote_path) }
it "MisMatchedChecksumError is raised" do
# Twice: #update retries on failure
@@ -28,10 +28,21 @@ RSpec.describe Bundler::CompactIndexClient::Updater do
end
end
+ context "when the download is corrupt" do
+ let(:response) { double(:response, :body => "") }
+
+ it "raises HTTPError" do
+ expect(response).to receive(:[]).with("Content-Encoding") { "gzip" }
+ expect(fetcher).to receive(:call) { response }
+
+ expect do
+ updater.update(local_path, remote_path)
+ end.to raise_error(Bundler::HTTPError)
+ end
+ end
+
context "when bundler doesn't have permissions on Dir.tmpdir" do
let(:response) { double(:response, :body => "") }
- let(:local_path) { Pathname("/tmp/localpath") }
- let(:remote_path) { double(:remote_path) }
it "Errno::EACCES is raised" do
allow(Dir).to receive(:mktmpdir) { raise Errno::EACCES }