Fix redirect display and chosen location

This commit is contained in:
Chris Roberts 2018-01-12 12:42:59 -08:00
parent 5c9c10558a
commit 5e7e56f573
1 changed files with 13 additions and 2 deletions

View File

@ -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