lib/vagrant/zscp/command/zscp.rb in vagrant-zscp-0.1.4 vs lib/vagrant/zscp/command/zscp.rb in vagrant-zscp-0.1.5
- old
+ new
@@ -41,24 +41,34 @@
next if !folders || folders.empty?
# Get the SSH info for this machine so we can access it
ssh_info = machine.ssh_info
- # Sync them!
- sync_threads = []
- folders.each do |id, folder_opts|
- sync_threads << Thread.new(id, folder_opts) do |id, folder_opts|
- ZscpHelper.scp(machine, ssh_info, folder_opts)
- end
+ # Clean up every synced folder first
+ foreach_folder(folders) do |folder_opts|
+ ZscpHelper.cleanup(machine, ssh_info, folder_opts)
end
- sync_threads.each do |t|
- t.join
+ # Clean up every synced folder first
+ foreach_folder(folders) do |folder_opts|
+ ZscpHelper.scp(machine, ssh_info, folder_opts)
end
end
return error ? 1 : 0
end
+
+ def foreach_folder(folders, &block)
+ sync_threads = []
+ folders.each do |id, folder_opts|
+ sync_threads << Thread.new(folder_opts) do |folder_opts|
+ block.call(folder_opts)
+ end
+ end
+ sync_threads.each do |t|
+ t.join
+ end
+ end
end
end
end
-end
\ No newline at end of file
+end