commands/version: use checkpoint data
This commit is contained in:
parent
09d2b6fd86
commit
140a1b8d4b
|
@ -130,10 +130,24 @@ module Vagrant
|
|||
# initialization. The cache file will cause this to mostly be a no-op
|
||||
# most of the time.
|
||||
@checkpoint_thr = Thread.new do
|
||||
@checkpoint_result = Checkpoint.check(
|
||||
Thread.current[:result] = nil
|
||||
|
||||
# If we disabled checkpoint via env var, don't run this
|
||||
if ENV["VAGRANT_CHECKPOINT_DISABLE"].to_s != ""
|
||||
next
|
||||
end
|
||||
|
||||
# If we disabled state and knowing what alerts we've seen, then
|
||||
# disable the signature file.
|
||||
signature_file = @data_dir.join("checkpoint_signature")
|
||||
if ENV["VAGRANT_CHECKPOINT_NO_STATE"].to_s != ""
|
||||
signature_file = nil
|
||||
end
|
||||
|
||||
Thread.current[:result] = Checkpoint.check(
|
||||
product: "vagrant",
|
||||
version: VERSION,
|
||||
signature_file: @data_dir.join("checkpoint_signature"),
|
||||
signature_file: signature_file,
|
||||
cache_file: @data_dir.join("checkpoint_cache"),
|
||||
)
|
||||
end
|
||||
|
@ -263,7 +277,7 @@ module Vagrant
|
|||
# @return [Hash]
|
||||
def checkpoint
|
||||
@checkpoint_thr.join
|
||||
return @checkpoint_result
|
||||
return @checkpoint_thr[:result]
|
||||
end
|
||||
|
||||
# Makes a call to the CLI with the given arguments as if they
|
||||
|
|
|
@ -38,25 +38,6 @@ module Vagrant
|
|||
ENV["VAGRANT_INSTALLER_EMBEDDED_DIR"]
|
||||
end
|
||||
|
||||
# Returns the latest version of Vagrant that is available.
|
||||
#
|
||||
# This makes an HTTP call.
|
||||
#
|
||||
# @return [String]
|
||||
def self.latest_version
|
||||
# Lazy-require this so that the overhead of this file is low
|
||||
require "vagrant/util/downloader"
|
||||
|
||||
tf = Tempfile.new("vagrant")
|
||||
tf.close
|
||||
url = "http://www.vagrantup.com/latest-version.json"
|
||||
Vagrant::Util::Downloader.new(url, tf.path).download!
|
||||
data = JSON.parse(File.read(tf.path))
|
||||
data["version"]
|
||||
ensure
|
||||
tf.unlink if tf
|
||||
end
|
||||
|
||||
# This returns whether or not 3rd party plugins should be loaded.
|
||||
#
|
||||
# @return [Boolean]
|
||||
|
|
|
@ -22,8 +22,15 @@ module VagrantPlugins
|
|||
"vagrant.version_current", version: Vagrant::VERSION))
|
||||
@env.ui.machine("version-installed", Vagrant::VERSION)
|
||||
|
||||
# Load the latest version
|
||||
latest = Vagrant.latest_version
|
||||
# Load the latest information
|
||||
cp = @env.checkpoint
|
||||
if !cp
|
||||
@env.ui.output("\n"+I18n.t(
|
||||
"vagrant.version_no_checkpoint"))
|
||||
return 0
|
||||
end
|
||||
|
||||
latest = cp["current_version"]
|
||||
|
||||
# Output latest version
|
||||
@env.ui.output(I18n.t(
|
||||
|
|
|
@ -229,6 +229,9 @@ en:
|
|||
Latest Version: %{version}
|
||||
version_latest_installed: |-
|
||||
You're running an up-to-date version of Vagrant!
|
||||
version_no_checkpoint: |-
|
||||
Vagrant was unable to check for the latest version of Vagrant.
|
||||
Please check manually at http://www.vagrantup.com
|
||||
version_upgrade_howto: |-
|
||||
To upgrade to the latest version, visit the downloads page and
|
||||
download and install the latest version of Vagrant from the URL
|
||||
|
|
Loading…
Reference in New Issue