Only prepare 10 shares per command to prevent exceeding allowed command size
When a large number of shares are defined it may cause the generated command to exceed the maximum allowed length. To prevent this, only allow 10 shares to be processed at a time. Fixes #10483
This commit is contained in:
parent
f7757b58d9
commit
924fb97e8c
|
@ -100,9 +100,14 @@ module VagrantPlugins
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
if !shares.empty?
|
if !shares.empty?
|
||||||
|
uac_notified = false
|
||||||
|
shares.each_slice(10) do |s_shares|
|
||||||
|
if !uac_notified
|
||||||
machine.env.ui.warn("\n" + I18n.t("vagrant_sf_smb.uac.create_warning") + "\n")
|
machine.env.ui.warn("\n" + I18n.t("vagrant_sf_smb.uac.create_warning") + "\n")
|
||||||
|
uac_notified = true
|
||||||
sleep(UAC_PROMPT_WAIT)
|
sleep(UAC_PROMPT_WAIT)
|
||||||
result = Vagrant::Util::PowerShell.execute(script_path, *shares, sudo: true)
|
end
|
||||||
|
result = Vagrant::Util::PowerShell.execute(script_path, *s_shares, sudo: true)
|
||||||
if result.exit_code != 0
|
if result.exit_code != 0
|
||||||
share_path = result.stdout.to_s.sub("share path: ", "")
|
share_path = result.stdout.to_s.sub("share path: ", "")
|
||||||
raise SyncedFolderSMB::Errors::DefineShareFailed,
|
raise SyncedFolderSMB::Errors::DefineShareFailed,
|
||||||
|
@ -112,6 +117,7 @@ module VagrantPlugins
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# Generate a list of existing local smb shares
|
# Generate a list of existing local smb shares
|
||||||
#
|
#
|
||||||
|
|
|
@ -228,6 +228,18 @@ Remark Not Vagrant Owned
|
||||||
expect(machine.env.ui).not_to receive(:warn)
|
expect(machine.env.ui).not_to receive(:warn)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "when more than 10 shares are defined" do
|
||||||
|
let(:folders) {
|
||||||
|
Hash[12.times.map{|i| ["/path#{i}", {hostpath: "/host#{i}"}]}]
|
||||||
|
}
|
||||||
|
|
||||||
|
after{ subject.smb_prepare(env, machine, folders, options) }
|
||||||
|
|
||||||
|
it "should execute multiple powershell commands" do
|
||||||
|
expect(Vagrant::Util::PowerShell).to receive(:execute).twice.with(any_args, sudo: true)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe ".get_smbshares" do
|
describe ".get_smbshares" do
|
||||||
|
|
Loading…
Reference in New Issue