From 10585b60b9f1b431a8df1add90ae15e5f2ebaf99 Mon Sep 17 00:00:00 2001 From: Anton Khorev Date: Thu, 28 Aug 2025 21:19:55 +0300 Subject: [PATCH] Lock changeset in api update 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 a585f5c88..beda01880 100644 --- a/app/controllers/api/nodes_controller.rb +++ b/app/controllers/api/nodes_controller.rb @@ -63,7 +63,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.update_from(new_node, current_user) + Changeset.transaction do + new_node.changeset&.lock! + node.update_from(new_node, current_user) + end render :plain => node.version.to_s end diff --git a/app/controllers/api/relations_controller.rb b/app/controllers/api/relations_controller.rb index 37c5cfc5e..fef0135a7 100644 --- a/app/controllers/api/relations_controller.rb +++ b/app/controllers/api/relations_controller.rb @@ -110,7 +110,10 @@ module Api raise OSM::APIBadUserInput, "The id in the url (#{relation.id}) is not the same as provided in the xml (#{new_relation.id})" unless new_relation && new_relation.id == relation.id - relation.update_from new_relation, current_user + Changeset.transaction do + new_relation.changeset&.lock! + relation.update_from(new_relation, current_user) + end render :plain => relation.version.to_s end diff --git a/app/controllers/api/ways_controller.rb b/app/controllers/api/ways_controller.rb index 05035d17c..4c58edf27 100644 --- a/app/controllers/api/ways_controller.rb +++ b/app/controllers/api/ways_controller.rb @@ -67,7 +67,10 @@ module Api raise OSM::APIBadUserInput, "The id in the url (#{way.id}) is not the same as provided in the xml (#{new_way.id})" unless new_way && new_way.id == way.id - way.update_from(new_way, current_user) + Changeset.transaction do + new_way.changeset&.lock! + way.update_from(new_way, current_user) + end render :plain => way.version.to_s end -- 2.39.5