core: return {} if cached synced folders file missing [GH-3550]

A missing synced folders cache indicates an empty cache, not a failure
that should be handled by the caller. The cache file is missing from
data dirs created by an earlier version of Vagrant.

Fixes #3550.
This commit is contained in:
Nikhil Benesch 2014-04-26 15:24:25 -04:00
parent 75ee7425f5
commit 54e580149a
2 changed files with 6 additions and 3 deletions

View File

@ -214,7 +214,10 @@ module Vagrant
end end
end end
rescue Errno::ENOENT rescue Errno::ENOENT
return nil # If the file doesn't exist, we probably just have a machine created
# by a version of Vagrant that didn't cache shared folders. Report no
# shared folders to be safe.
return {}
end end
end end
end end

View File

@ -136,9 +136,9 @@ describe Vagrant::Action::Builtin::MixinSyncedFolders do
expect(result[:nfs]["root"][:foo]).to eql("bar") expect(result[:nfs]["root"][:foo]).to eql("bar")
end end
it "returns nil if cached read with no cache" do it "returns {} if cached read with no cache" do
result = subject.synced_folders(machine, cached: true) result = subject.synced_folders(machine, cached: true)
expect(result).to be_nil expect(result).to eql({})
end end
it "should be able to save and retrieve cached versions" do it "should be able to save and retrieve cached versions" do