X-Git-Url: https://git.openstreetmap.org/rails.git/blobdiff_plain/41f85fb77dbd0c16f12e49091b14fcaa1264ad70..f7cbff9a5aee62de4ad2aea088d6939a07bbdbcc:/app/controllers/amf_controller.rb diff --git a/app/controllers/amf_controller.rb b/app/controllers/amf_controller.rb index 5ff42fdd2..b6d8cbe53 100644 --- a/app/controllers/amf_controller.rb +++ b/app/controllers/amf_controller.rb @@ -362,7 +362,7 @@ class AmfController < ApplicationController waycreated=revdates[0] revdates.uniq! revdates.sort! - revdates.reverse! + revdates.reverse! # Remove any dates (from nodes) before first revision date of way revdates.delete_if { |d| d ex + # We don't do anything here as the node is being used elsewhere + # and we don't want to delete it + end end + updatetimeout(changeset_id) end # transaction @@ -690,7 +697,9 @@ class AmfController < ApplicationController # We're deleting the node node.delete_with_history!(new_node, user) end - end # transaction + updatetimeout(changeset_id) + + end # transaction if id <= 0 return [0, id, new_node.id, new_node.version] @@ -763,8 +772,14 @@ class AmfController < ApplicationController new_node = Node.new new_node.changeset_id = changeset_id new_node.version = v.to_i - node.delete_with_history_unless_used!(new_node, user) + begin + node.delete_with_history!(new_node, user) + rescue OSM::APIPreconditionFailedError => ex + # We don't do anything with the exception as the node is in use + # elsewhere and we don't want to delete it + end end + updatetimeout(changeset_id) end # transaction [0, way_id] @@ -800,6 +815,15 @@ class AmfController < ApplicationController return user end + # Update changeset timeout + # i.e. one hour after current edit + + def updatetimeout(changeset_id) #:doc: + cs = Changeset.find(changeset_id) + cs.closed_at = Time.now.getutc + Changeset::IDLE_TIMEOUT + cs.save! + end + # Send AMF response def sendresponse(results)