From c875e4345af3c811bac9e6a2fb3a4387cfbf89d1 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Tue, 20 Jul 2010 13:18:00 -0700 Subject: [PATCH] Expand the NFS shared folder path relative to root path during the extraction. --- lib/vagrant/action/vm/nfs.rb | 10 +++------- test/vagrant/action/vm/nfs_test.rb | 8 ++++++++ vagrant.gemspec | 2 +- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/lib/vagrant/action/vm/nfs.rb b/lib/vagrant/action/vm/nfs.rb index 30116a108..476420bef 100644 --- a/lib/vagrant/action/vm/nfs.rb +++ b/lib/vagrant/action/vm/nfs.rb @@ -48,13 +48,6 @@ module Vagrant # Returns the folders which are to be synced via NFS. def folders @folders ||= {} - @folders.inject({}) do |acc, data| - key, opts = data - opts = opts.dup - opts[:hostpath] = File.expand_path(opts[:hostpath], @env.env.root_path) - acc[key] = opts - acc - end end # Removes the NFS enabled shared folders from the configuration, @@ -66,7 +59,10 @@ module Vagrant key, opts = data if opts[:nfs] + # Duplicate the options, set the hostpath, and set disabled on the original + # options so the ShareFolders middleware doesn't try to mount it. acc[key] = opts.dup + acc[key][:hostpath] = File.expand_path(opts[:hostpath], @env.env.root_path) opts[:disabled] = true end diff --git a/test/vagrant/action/vm/nfs_test.rb b/test/vagrant/action/vm/nfs_test.rb index 8ddf6806e..aa24040a7 100644 --- a/test/vagrant/action/vm/nfs_test.rb +++ b/test/vagrant/action/vm/nfs_test.rb @@ -112,6 +112,14 @@ class NFSVMActionTest < Test::Unit::TestCase assert @env["config"].vm.shared_folders[key][:disabled] end end + + should "expand the hostpath relative to the env root" do + @instance.extract_folders + %W[v-foo v-bar].each do |key| + opts = @env["config"].vm.shared_folders[key] + assert_equal File.expand_path(opts[:hostpath], @env.env.root_path), @instance.folders[key][:hostpath] + end + end end context "preparing UID/GID" do diff --git a/vagrant.gemspec b/vagrant.gemspec index 32fff1e4d..6459e46a4 100644 --- a/vagrant.gemspec +++ b/vagrant.gemspec @@ -9,7 +9,7 @@ Gem::Specification.new do |s| s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version= s.authors = ["Mitchell Hashimoto", "John Bender"] - s.date = %q{2010-07-19} + s.date = %q{2010-07-20} s.default_executable = %q{vagrant} s.description = %q{Vagrant is a tool for building and distributing virtualized development environments.} s.email = ["mitchell.hashimoto@gmail.com", "john.m.bender@gmail.com"]