From 5e7e56f5730e0430eba371b7cbbdb5bd4bec5bc4 Mon Sep 17 00:00:00 2001 From: Chris Roberts Date: Fri, 12 Jan 2018 12:42:59 -0800 Subject: [PATCH] Fix redirect display and chosen location --- lib/vagrant/util/downloader.rb | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/vagrant/util/downloader.rb b/lib/vagrant/util/downloader.rb index b22145d9e..eda284db0 100644 --- a/lib/vagrant/util/downloader.rb +++ b/lib/vagrant/util/downloader.rb @@ -25,6 +25,12 @@ module Vagrant :sha1 => Digest::SHA1 }.freeze + # Hosts that do not require notification on redirect + SILENCED_HOSTS = [ + "vagrantcloud.com".freeze, + "vagrantup.com".freeze + ].freeze + attr_reader :source attr_reader :destination @@ -106,16 +112,21 @@ module Vagrant # from the original host, notify the user that the target host has # changed from the source. if progress_data.include?("Location") - location = progress_data.scan(/Location: (.+?)$/m).flatten.compact.last.to_s.strip + location = progress_data.scan(/Location: (.+?)$/m).flatten.compact.first.to_s.strip if !location.empty? @logger.info("download redirected to #{location}") location_uri = URI.parse(location) source_uri = URI.parse(source) - if location_uri.host != source_uri.host + source_host = source_uri.host.split(".", 2).last + location_host = location_uri.host.split(".", 2).last + if !@redirect_notify && location_host != source_host && !SILENCED_HOSTS.include?(location_host) @ui.clear_line @ui.detail "Download redirected to host: #{location_uri.host}" end + @redirect_notify = true end + progress_data.replace("") + break end data = match[1].to_s