From 88725929e46c62e3a786e28d9466a98eafdace8b Mon Sep 17 00:00:00 2001 From: Anton Khorev Date: Thu, 28 Aug 2025 21:24:12 +0300 Subject: [PATCH] Lock changeset in api destroy element actions --- app/controllers/api/nodes_controller.rb | 5 ++++- app/controllers/api/relations_controller.rb | 5 ++++- app/controllers/api/ways_controller.rb | 5 ++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/app/controllers/api/nodes_controller.rb b/app/controllers/api/nodes_controller.rb index beda01880..164f70f8d 100644 --- a/app/controllers/api/nodes_controller.rb +++ b/app/controllers/api/nodes_controller.rb @@ -79,7 +79,10 @@ module Api raise OSM::APIBadUserInput, "The id in the url (#{node.id}) is not the same as provided in the xml (#{new_node.id})" unless new_node && new_node.id == node.id - node.delete_with_history!(new_node, current_user) + Changeset.transaction do + new_node.changeset&.lock! + node.delete_with_history!(new_node, current_user) + end render :plain => node.version.to_s end end diff --git a/app/controllers/api/relations_controller.rb b/app/controllers/api/relations_controller.rb index fef0135a7..3059cfae3 100644 --- a/app/controllers/api/relations_controller.rb +++ b/app/controllers/api/relations_controller.rb @@ -121,7 +121,10 @@ module Api relation = Relation.find(params[:id]) new_relation = Relation.from_xml(request.raw_post) if new_relation && new_relation.id == relation.id - relation.delete_with_history!(new_relation, current_user) + Changeset.transaction do + new_relation.changeset&.lock! + relation.delete_with_history!(new_relation, current_user) + end render :plain => relation.version.to_s else head :bad_request diff --git a/app/controllers/api/ways_controller.rb b/app/controllers/api/ways_controller.rb index 4c58edf27..6941bcfb8 100644 --- a/app/controllers/api/ways_controller.rb +++ b/app/controllers/api/ways_controller.rb @@ -80,7 +80,10 @@ module Api new_way = Way.from_xml(request.raw_post) if new_way && new_way.id == way.id - way.delete_with_history!(new_way, current_user) + Changeset.transaction do + new_way.changeset&.lock! + way.delete_with_history!(new_way, current_user) + end render :plain => way.version.to_s else head :bad_request -- 2.39.5