Fix redirect display and chosen location
This commit is contained in:
parent
5c9c10558a
commit
5e7e56f573
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue