Method: Vagrant::Action::Builtin::MixinSyncedFolders#synced_folders_diff
- Defined in:
- lib/vagrant/action/builtin/mixin_synced_folders.rb
#synced_folders_diff(one, two) ⇒ hash
This finds the difference between two lists of synced folder definitions.
This will return a hash with three keys: "added", "removed", and "modified". These will contain a set of IDs of folders that were added, removed, or modified, respectively.
The parameters should be results from the #synced_folders call.
207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 |
# File 'lib/vagrant/action/builtin/mixin_synced_folders.rb', line 207 def synced_folders_diff(one, two) existing_ids = {} one.each do |impl, fs| fs.each do |id, data| existing_ids[id] = data end end result = Hash.new { |h, k| h[k] = Set.new } two.each do |impl, fs| fs.each do |id, data| existing = existing_ids.delete(id) if !existing result[:added] << id next end # Exists, so we have to compare the host and guestpath, which # is most important... if existing[:hostpath] != data[:hostpath] || existing[:guestpath] != data[:guestpath] result[:modified] << id end end end existing_ids.each do |k, _| result[:removed] << k end result end |