From d3fffd65d254a3d40276a4984786473866ef9c1a Mon Sep 17 00:00:00 2001 From: Chris Roberts Date: Mon, 15 Mar 2021 15:21:07 -0700 Subject: [PATCH] Prevent notifications on redirect to default store This also checks if the redirect notification has been displayed before inspecting the source and location to prevent repeat checks after the notification has been sent. --- lib/vagrant/util/curl_helper.rb | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/vagrant/util/curl_helper.rb b/lib/vagrant/util/curl_helper.rb index 8c3d205d9..07e0a5dbf 100644 --- a/lib/vagrant/util/curl_helper.rb +++ b/lib/vagrant/util/curl_helper.rb @@ -4,6 +4,7 @@ module Vagrant # Hosts that do not require notification on redirect SILENCED_HOSTS = [ + "vagrantcloud-files-production.s3-accelerate.amazonaws.com".freeze, "vagrantcloud.com".freeze, "vagrantup.com".freeze ].freeze @@ -21,6 +22,7 @@ module Vagrant # Accumulate progress_data progress_data << data + redirect_notify = false while true # If the download has been redirected and we are no longer downloading # from the original host, notify the user that the target host has @@ -30,16 +32,15 @@ module Vagrant if !location.empty? location_uri = URI.parse(location) - unless location_uri.host.nil? - redirect_notify = false + if !location_uri.host.nil? && !redirect_notify logger.info("download redirected to #{location}") source_uri = URI.parse(source) source_host = source_uri.host.to_s.split(".", 2).last location_host = location_uri.host.to_s.split(".", 2).last - if !redirect_notify && location_host != source_host && !SILENCED_HOSTS.include?(location_host) - ui.rewriting do |ui| - ui.clear_line - ui.detail "Download redirected to host: #{location_uri.host}" + if location_host != source_host && !SILENCED_HOSTS.include?(location_host) && !SILENCED_HOSTS.include?(location_uri.host.to_s) + ui.rewriting do |_ui| + _ui.clear_line + _ui.detail "Download redirected to host: #{location_uri.host}" end end redirect_notify = true