X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/dc2a95903722644f6109244cec9a2d1e195fef0e..acc5ffbe1ca930676ec0ec71592e2b37d9029ce6:/lib/diff_reader.rb?ds=sidebyside diff --git a/lib/diff_reader.rb b/lib/diff_reader.rb index eca6d438c..6a053e4ad 100644 --- a/lib/diff_reader.rb +++ b/lib/diff_reader.rb @@ -79,6 +79,7 @@ class DiffReader ids = { :node => node_ids, :way => way_ids, :relation => rel_ids} result = OSM::API.new.get_xml_doc + result.root.name = "diffResult" # loop at the top level, within the element (although we # don't actually check this...) @@ -99,9 +100,8 @@ class DiffReader # diff, so we must fix these before saving the element. new.fix_placeholders!(ids) - # set the initial version to zero and save (which increments it) - new.version = 0 - new.save_with_history! + # create element given user + new.create_with_history(@changeset.user) # save placeholder => allocated ID map ids[model.to_s.downcase.to_sym][placeholder_id] = new.id @@ -130,8 +130,10 @@ class DiffReader xml_result = XML::Node.new model.to_s.downcase xml_result["old_id"] = old.id.to_s - xml_result["new_id"] = new.id.to_s - xml_result["new_version"] = new.version.to_s + xml_result["new_id"] = new.id.to_s + # version is updated in "old" through the update, so we must not + # return new.version here but old.version! + xml_result["new_version"] = old.version.to_s result.root << xml_result end @@ -156,7 +158,7 @@ class DiffReader else # no other actions to choose from, so it must be the users fault! - raise "Unknown action #{action_name}, choices are create, modify, delete." + raise OSM::APIChangesetActionInvalid.new(action_name) end end