1 # frozen_string_literal: true
5 class UploadsController < ApiController
6 before_action :check_api_writable
7 before_action :authorize
9 authorize_resource :class => Changeset
11 before_action :require_public_data
13 skip_around_action :api_call_timeout
15 # Helper methods for checking consistency
16 include ConsistencyValidations
19 # Upload a diff in a single transaction.
21 # This means that each change within the diff must succeed, i.e: that
22 # each version number mentioned is still current. Otherwise the entire
23 # transaction *must* be rolled back.
25 # Furthermore, each element in the diff can only reference the current
28 # Returns: a diffResult document, as described in
29 # http://wiki.openstreetmap.org/wiki/OSM_Protocol_Version_0.6
31 changeset = Changeset.find(params[:changeset_id])
32 check_changeset_consistency(changeset, current_user)
34 diff_reader = DiffReader.new(request.raw_post, changeset)
35 Changeset.transaction do
36 result = diff_reader.commit
37 # the number of changes in this changeset has already been
38 # updated and is visible in this transaction so we don't need
39 # to allow for any more when checking the limit
41 render :xml => result.to_s