X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/20aa4ba31b61a926c8fcb98f88c02f7d1cbeb655..a402e811dac1f999dcf623ce6099e554d76c6de4:/app/models/node.rb?ds=inline diff --git a/app/models/node.rb b/app/models/node.rb index 2a64259c1..f4367e459 100644 --- a/app/models/node.rb +++ b/app/models/node.rb @@ -232,14 +232,18 @@ class Node < ActiveRecord::Base def save_with_history! t = Time.now.getutc + + self.version += 1 + self.timestamp = t + Node.transaction do - self.version += 1 - self.timestamp = t - save! + # clone the object before saving it so that the original is + # still marked as dirty if we retry the transaction + clone.save! # Create a NodeTag tags = self.tags - NodeTag.delete_all(:node_id => id) + NodeTag.where(:node_id => id).delete_all tags.each do |k, v| tag = NodeTag.new tag.node_id = id