Fix crashing bug if .vagrant is invalid. [closes GH-496]
This commit is contained in:
parent
5d993e76ec
commit
1cfef2734a
|
@ -1,6 +1,7 @@
|
|||
## 0.8.7 (unreleased)
|
||||
|
||||
- Fix regression with remote paths from chef-solo. [GH-431]
|
||||
- Fix issue where Vagrant crashes if `.vagrant` file becomes invalid. [GH-496]
|
||||
|
||||
## 0.8.6 (August 28, 2011)
|
||||
|
||||
|
|
|
@ -23,7 +23,12 @@ module Vagrant
|
|||
|
||||
if File.exist?(file_path)
|
||||
File.open(file_path, "r") do |f|
|
||||
begin
|
||||
merge!(JSON.parse(f.read))
|
||||
rescue JSON::ParserError
|
||||
# Ignore if the data is invalid in the file.
|
||||
# TODO: Log here.
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -23,6 +23,14 @@ class DataStoreTest < Test::Unit::TestCase
|
|||
}
|
||||
end
|
||||
|
||||
should "initialize just fine if the db file contains invalid data" do
|
||||
file = tmp_path.join("data_store_empty_test")
|
||||
File.open(file, "w") { |f| f.write("") }
|
||||
|
||||
instance = @klass.new(file)
|
||||
assert instance.length == 0
|
||||
end
|
||||
|
||||
should "be a hash with indifferent access" do
|
||||
assert @instance.is_a?(Vagrant::Util::HashWithIndifferentAccess)
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue