From cabacae4cbe1cdbc062a7ab1bcec447bdb6cdaf2 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Wed, 16 Apr 2014 13:48:46 -0700 Subject: [PATCH] core: return nil if cached synced folders file doesn't exist --- lib/vagrant/action/builtin/mixin_synced_folders.rb | 2 ++ .../unit/vagrant/action/builtin/mixin_synced_folders_test.rb | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/lib/vagrant/action/builtin/mixin_synced_folders.rb b/lib/vagrant/action/builtin/mixin_synced_folders.rb index 11948cf50..949ec8444 100644 --- a/lib/vagrant/action/builtin/mixin_synced_folders.rb +++ b/lib/vagrant/action/builtin/mixin_synced_folders.rb @@ -168,6 +168,8 @@ module Vagrant r.delete(k) end end + rescue Errno::ENOENT + return nil end end end diff --git a/test/unit/vagrant/action/builtin/mixin_synced_folders_test.rb b/test/unit/vagrant/action/builtin/mixin_synced_folders_test.rb index 0122ccc97..769d2c385 100644 --- a/test/unit/vagrant/action/builtin/mixin_synced_folders_test.rb +++ b/test/unit/vagrant/action/builtin/mixin_synced_folders_test.rb @@ -136,6 +136,11 @@ describe Vagrant::Action::Builtin::MixinSyncedFolders do expect(result[:nfs]["root"][:foo]).to eql("bar") end + it "returns nil if cached read with no cache" do + result = subject.synced_folders(machine, nil, cached: true) + expect(result).to be_nil + end + it "should be able to save and retrieve cached versions" do folders["root"] = {} folders["another"] = { type: "" }