Method: Chef::ChefFS::FileSystem.compare

Defined in:
lib/chef/chef_fs/file_system.rb

.compare(a, b) ⇒ Object



246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
# File 'lib/chef/chef_fs/file_system.rb', line 246

def self.compare(a, b)
  are_same, a_value, b_value = a.compare_to(b)
  if are_same.nil?
    are_same, b_value, a_value = b.compare_to(a)
  end
  if are_same.nil?
    # TODO these reads can be parallelized
    begin
      a_value = a.read if a_value.nil?
    rescue Chef::ChefFS::FileSystem::NotFoundError
      a_value = :none
    end
    begin
      b_value = b.read if b_value.nil?
    rescue Chef::ChefFS::FileSystem::NotFoundError
      b_value = :none
    end
    are_same = (a_value == b_value)
  end
  [ are_same, a_value, b_value ]
end