Fixed using proper method to convert Linux path to Windows style

This commit is contained in:
Zhongcheng Lao 2019-06-20 22:09:10 +08:00
parent 669b7b3709
commit 0aa034e870
5 changed files with 8 additions and 8 deletions

View File

@ -487,11 +487,11 @@ module Vagrant
#
# @param [Pathname, String] path Path to convert
# @return [String]
def windows_path(path)
def windows_path(path, *args)
path = cygwin_windows_path(path)
path = wsl_to_windows_path(path)
if windows? || wsl?
path = windows_unc_path(path)
path = windows_unc_path(path) if !args.include?(:disable_unc)
end
path
end

View File

@ -10,7 +10,7 @@ module VagrantPlugins
is_win_guest = machine.guest.name == :windows
host_path = VagrantPlugins::HyperV::SyncHelper.expand_path(data[:hostpath])
guest_path = data[:guestpath]
win_host_path = Vagrant::Util::Platform.format_windows_path(
win_host_path = Vagrant::Util::Platform.windows_path(
host_path, :disable_unc)
win_guest_path = guest_path.tr '/', '\\'

View File

@ -239,7 +239,7 @@ module VagrantPlugins
File.open(fn, 'w') do |file|
file.write files.to_json
end
win_path = Vagrant::Util::Platform.format_windows_path(
win_path = Vagrant::Util::Platform.windows_path(
fn, :disable_unc)
status = execute(:sync_files,
vm_id: vm_id,

View File

@ -169,7 +169,7 @@ describe VagrantPlugins::HyperV::Cap::SyncFolder do
allow(guest).to receive(:name).and_return(guest_type)
allow(VagrantPlugins::HyperV::SyncHelper).to receive(:expand_path).
with(hostpath).and_return(expanded_hostpath)
allow(Vagrant::Util::Platform).to receive(:format_windows_path).
allow(Vagrant::Util::Platform).to receive(:windows_path).
with(expanded_hostpath, :disable_unc).and_return(expanded_hostpath_windows)
allow(described_class).to receive(:find_includes).
with(hostpath, exclude).and_return(includes)
@ -186,7 +186,7 @@ describe VagrantPlugins::HyperV::Cap::SyncFolder do
end
it "formats expanded full path to windows path" do
expect(Vagrant::Util::Platform).to receive(:format_windows_path).
expect(Vagrant::Util::Platform).to receive(:windows_path).
with(expanded_hostpath, :disable_unc).and_return(expanded_hostpath_windows)
end

View File

@ -140,7 +140,7 @@ describe VagrantPlugins::HyperV::Driver do
allow(File).to receive(:open) do |fn, type, &proc|
proc.call file_list
allow(Vagrant::Util::Platform).to receive(:format_windows_path).
allow(Vagrant::Util::Platform).to receive(:windows_path).
with(fn, :disable_unc).and_return(windows_path)
allow(FileUtils).to receive(:rm_f).with(fn)
end.and_return(file_list)
@ -184,7 +184,7 @@ describe VagrantPlugins::HyperV::Driver do
proc.call file_list
expect(Vagrant::Util::Platform).to receive(:format_windows_path).
expect(Vagrant::Util::Platform).to receive(:windows_path).
with(fn, :disable_unc).and_return(windows_path)
expect(FileUtils).to receive(:rm_f).with(fn)
end.and_return(file_list)