synced_folders/rsync: run hostpath through fs_real_path

This fixes issues with drive letter casing on Windows
This commit is contained in:
Mitchell Hashimoto 2014-01-15 11:30:32 -08:00
parent 8a56d0ae5e
commit 4fab57576b
3 changed files with 17 additions and 2 deletions

View File

@ -60,7 +60,18 @@ module Vagrant
# of the path.
def fs_real_path(path)
path = Pathname.new(File.expand_path(path))
raise "Path must exist for path expansion" if !path.exist?
if windows?
# Fix the drive letter to be uppercase.
path = path.to_s
if path[1] == ":"
path[0] = path[0].upcase
end
path = Pathname.new(path)
end
return path if !path.exist?
return path if fs_case_sensitive?
# Build up all the parts of the path

View File

@ -1,3 +1,4 @@
require "vagrant/util/platform"
require "vagrant/util/subprocess"
module VagrantPlugins
@ -10,6 +11,7 @@ module VagrantPlugins
guestpath = opts[:guestpath]
hostpath = opts[:hostpath]
hostpath = File.expand_path(hostpath, machine.env.root_path)
hostpath = Vagrant::Util::Platform.fs_real_path(hostpath).to_s
# Connection information
username = ssh_info[:username]

View File

@ -1,5 +1,7 @@
require_relative "../../../base"
require "vagrant/util/platform"
require Vagrant.source_root.join("plugins/synced_folders/rsync/helper")
describe VagrantPlugins::SyncedFolderRSync::RsyncHelper do
@ -56,7 +58,7 @@ describe VagrantPlugins::SyncedFolderRSync::RsyncHelper do
opts[:guestpath] = "/bar"
Vagrant::Util::Subprocess.should_receive(:execute).with do |*args|
expect(args[args.length - 3]).to eql("/foo")
expect(args[args.length - 3]).to eql(Vagrant::Util::Platform.fs_real_path("/foo").to_s)
expect(args[args.length - 2]).to include("/bar")
end