core: initialize synced folder class only once [GH-3067]
This commit is contained in:
parent
46b5f0d22b
commit
79df69392f
|
@ -53,19 +53,26 @@ module Vagrant
|
|||
end
|
||||
end
|
||||
|
||||
# Build up the instances of the synced folders. We do this once
|
||||
# so that they can store state.
|
||||
folders = folders.map do |impl_name, fs|
|
||||
instance = plugins[impl_name.to_sym][0].new
|
||||
[instance, impl_name, fs]
|
||||
end
|
||||
|
||||
# Go through each folder and prepare the folders
|
||||
folders.each do |impl_name, fs|
|
||||
folders.each do |impl, impl_name, fs|
|
||||
@logger.info("Invoking synced folder prepare for: #{impl_name}")
|
||||
plugins[impl_name.to_sym][0].new.prepare(env[:machine], fs, impl_opts(impl_name, env))
|
||||
impl.prepare(env[:machine], fs, impl_opts(impl_name, env))
|
||||
end
|
||||
|
||||
# Continue, we need the VM to be booted.
|
||||
@app.call(env)
|
||||
|
||||
# Once booted, setup the folder contents
|
||||
folders.each do |impl_name, fs|
|
||||
folders.each do |impl, impl_name, fs|
|
||||
@logger.info("Invoking synced folder enable: #{impl_name}")
|
||||
plugins[impl_name.to_sym][0].new.enable(env[:machine], fs, impl_opts(impl_name, env))
|
||||
impl.enable(env[:machine], fs, impl_opts(impl_name, env))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -62,13 +62,16 @@ describe Vagrant::Action::Builtin::SyncedFolders do
|
|||
end
|
||||
|
||||
it "should invoke prepare then enable" do
|
||||
ids = []
|
||||
order = []
|
||||
tracker = Class.new(impl(true, "good")) do
|
||||
define_method(:prepare) do |machine, folders, opts|
|
||||
ids << self.object_id
|
||||
order << :prepare
|
||||
end
|
||||
|
||||
define_method(:enable) do |machine, folders, opts|
|
||||
ids << self.object_id
|
||||
order << :enable
|
||||
end
|
||||
end
|
||||
|
@ -89,6 +92,8 @@ describe Vagrant::Action::Builtin::SyncedFolders do
|
|||
subject.call(env)
|
||||
|
||||
order.should == [:prepare, :enable]
|
||||
expect(ids.length).to eq(2)
|
||||
expect(ids[0]).to eq(ids[1])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue