lib/trackman/components/diffable.rb in trackman-0.6.9 vs lib/trackman/components/diffable.rb in trackman-0.6.10

- old
+ new

@@ -4,11 +4,11 @@ def diff local, remote to_create = local.select{|a| remote.all? { |s| a.path != s.path } }.map{|a| a.to_remote } { :create => to_create, - :update => remote.select{|a| local.any?{ |s| a.path == s.path && (a.file_hash != s.file_hash || a.virtual_path != s.virtual_path) }}, + :update => define_update(local, remote), :delete => define_deleted(local, remote) do |a| to_create.any?{ |c| c.path.basename == a.path.basename } end } end @@ -21,8 +21,26 @@ local.all? { |s| s.path != a.path } end to_delete.reject{|a| a.path.to_s =~ /.html$/ }.to_a end + + def define_update local, remote + to_update = local.select do |l| + remote.any? do |r| + path_eql = a.path == s.path + hash_eql = a.file_hash == s.file_hash + vp_eql = a.virtual_path == s.virtual_path + + path_eql && (!hash_eql || !vp_eql) + end + end + + to_update.map do |a| + sibling = remote.select{|x| x.path == a.path }.first + a.to_remote(sibling.id) + end + end + end end end \ No newline at end of file