Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id B1068200C5B for ; Tue, 14 Mar 2017 20:25:58 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id AF974160B96; Tue, 14 Mar 2017 19:25:58 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id E7988160B7E for ; Tue, 14 Mar 2017 20:25:57 +0100 (CET) Received: (qmail 48270 invoked by uid 500); 14 Mar 2017 19:25:56 -0000 Mailing-List: contact commits-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list commits@couchdb.apache.org Received: (qmail 48047 invoked by uid 99); 14 Mar 2017 19:25:56 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 14 Mar 2017 19:25:56 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 0EF10DFE20; Tue, 14 Mar 2017 19:25:56 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: vatamane@apache.org To: commits@couchdb.apache.org Date: Tue, 14 Mar 2017 19:25:57 -0000 Message-Id: <0a4a381981004477a6c9e73bba646fb1@git.apache.org> In-Reply-To: <5a40ed67f6bf401bbfa1d0ee49ec37be@git.apache.org> References: <5a40ed67f6bf401bbfa1d0ee49ec37be@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [02/50] couch-replicator commit: updated refs/heads/63012-scheduler to 27a5eae archived-at: Tue, 14 Mar 2017 19:25:58 -0000 Canceling a transient replication via a "replication_id" works again Canceling a transient replication by POST-ing to _replicate was failing because it was assumed request body had to always be well-formed (with source, target, ...). However it is valid to cancel a replication with a body which has just `"cancel": true` and either `replication_id`, `id` or `_local_id` fields. Example: Creating a transient continuous replication ``` http --auth=adm:pass :15984/_replicate \ source='http://adm:pass@localhost:15984/s' \ target='http://adm:pass@localhost:15984/r' \ create_target:='true' \ continuous:='true' { "_local_id": "14ed9e9f8411232bdcd2387a8f578806+continuous+create_target", "ok": true } ``` Canceling ``` http --auth=adm:pass :15984/_replicate \ cancel:='true' \ replication_id='14ed9e9f8411232bdcd2387a8f578806+continuous+create_target' { "_local_id": "14ed9e9f8411232bdcd2387a8f578806+continuous+create_target", "ok": true } ``` Log shows: ``` Canceling replication '14ed9e9f8411232bdcd2387a8f578806+continuous+create_target' ``` Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/commit/c9f04862 Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/tree/c9f04862 Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/diff/c9f04862 Branch: refs/heads/63012-scheduler Commit: c9f04862f7431845919476421dbaab4468d2de71 Parents: 26fc4df Author: Nick Vatamaniuc Authored: Thu Oct 20 23:47:26 2016 -0400 Committer: Nick Vatamaniuc Committed: Thu Oct 20 23:47:26 2016 -0400 ---------------------------------------------------------------------- src/couch_replicator_docs.erl | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/blob/c9f04862/src/couch_replicator_docs.erl ---------------------------------------------------------------------- diff --git a/src/couch_replicator_docs.erl b/src/couch_replicator_docs.erl index a3e6b35..777c8a4 100644 --- a/src/couch_replicator_docs.erl +++ b/src/couch_replicator_docs.erl @@ -194,7 +194,12 @@ parse_rep_doc_without_id(RepDoc) -> -spec parse_rep_doc({[_]}, #user_ctx{}) -> {ok, #rep{}}. parse_rep_doc(Doc, UserCtx) -> {ok, Rep} = parse_rep_doc_without_id(Doc, UserCtx), - {ok, update_rep_id(Rep)}. + case get_value(cancel, Rep#rep.options, false) of + true -> + {ok, Rep}; + false -> + {ok, update_rep_id(Rep)} + end. -spec parse_rep_doc_without_id({[_]}, #user_ctx{}) -> {ok, #rep{}}.