summaryrefslogtreecommitdiff
path: root/lib/bundler/compact_index_client/updater.rb
diff options
context:
space:
mode:
authorDavid Rodríguez <deivid.rodriguez@riseup.net>2021-04-21 13:54:29 +0200
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2021-05-11 11:29:41 +0900
commit5b0abba9317f206913cf2e599d0dac7e9dbd0baa (patch)
tree81e092eaf8b048df4d64eebe8b1c51626f751e9b /lib/bundler/compact_index_client/updater.rb
parent15160e9b4feba5d531601a4f626b3132d4749629 (diff)
Sync bundler & rubygems
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/4367
Diffstat (limited to 'lib/bundler/compact_index_client/updater.rb')
-rw-r--r--lib/bundler/compact_index_client/updater.rb10
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/bundler/compact_index_client/updater.rb b/lib/bundler/compact_index_client/updater.rb
index b4b2321797..06486f98cb 100644
--- a/lib/bundler/compact_index_client/updater.rb
+++ b/lib/bundler/compact_index_client/updater.rb
@@ -50,16 +50,20 @@ module Bundler
content = response.body
- SharedHelpers.filesystem_access(local_temp_path) do
+ etag = (response["ETag"] || "").gsub(%r{\AW/}, "")
+ correct_response = SharedHelpers.filesystem_access(local_temp_path) do
if response.is_a?(Net::HTTPPartialContent) && local_temp_path.size.nonzero?
local_temp_path.open("a") {|f| f << slice_body(content, 1..-1) }
+
+ etag_for(local_temp_path) == etag
else
local_temp_path.open("wb") {|f| f << content }
+
+ etag.length.zero? || etag_for(local_temp_path) == etag
end
end
- etag = (response["ETag"] || "").gsub(%r{\AW/}, "")
- if etag.length.zero? || etag_for(local_temp_path) == etag
+ if correct_response
SharedHelpers.filesystem_access(local_path) do
FileUtils.mv(local_temp_path, local_path)
end