You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by da...@apache.org on 2014/12/12 21:35:34 UTC

[1/2] fabric commit: updated refs/heads/master to 9e87f8b

Repository: couchdb-fabric
Updated Branches:
  refs/heads/master 5930256ad -> 9e87f8b3f


Add system db handlers to fabric_doc_update

This hard codes the before_doc_write functions for replicator and user
databases like they are in couch_server. This is mostly motivated by the
fact that couch_users_db:before_doc_update/1 adds random salt values to
user documents when a password is changed. The replicator databases are
included at this level for consistency with couch_server.

COUCHDB-2510


Project: http://git-wip-us.apache.org/repos/asf/couchdb-fabric/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-fabric/commit/4e0e81fd
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-fabric/tree/4e0e81fd
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-fabric/diff/4e0e81fd

Branch: refs/heads/master
Commit: 4e0e81fd9d668bf4d532864b9cab3ad2d7653d50
Parents: 5930256
Author: Paul J. Davis <pa...@gmail.com>
Authored: Thu Dec 11 20:13:57 2014 -0600
Committer: Paul J. Davis <pa...@gmail.com>
Committed: Thu Dec 11 20:13:57 2014 -0600

----------------------------------------------------------------------
 src/fabric_doc_update.erl | 25 ++++++++++++++++++++++++-
 1 file changed, 24 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-fabric/blob/4e0e81fd/src/fabric_doc_update.erl
----------------------------------------------------------------------
diff --git a/src/fabric_doc_update.erl b/src/fabric_doc_update.erl
index f593b12..4febe13 100644
--- a/src/fabric_doc_update.erl
+++ b/src/fabric_doc_update.erl
@@ -21,7 +21,8 @@
 go(_, [], _) ->
     {ok, []};
 go(DbName, AllDocs0, Opts) ->
-    AllDocs = tag_docs(AllDocs0),
+    AllDocs1 = before_doc_update(DbName, AllDocs0),
+    AllDocs = tag_docs(AllDocs1),
     validate_atomic_update(DbName, AllDocs, lists:member(all_or_nothing, Opts)),
     Options = lists:delete(all_or_nothing, Opts),
     GroupedDocs = lists:map(fun({#shard{name=Name, node=Node} = Shard, Docs}) ->
@@ -97,6 +98,28 @@ handle_message({not_found, no_db_file} = X, Worker, Acc0) ->
 handle_message({bad_request, Msg}, _, _) ->
     throw({bad_request, Msg}).
 
+before_doc_update(DbName, Docs) ->
+    case {is_replicator_db(DbName), is_users_db(DbName)} of
+        {true, _} ->
+            lists:map(fun couch_replicator_manager:before_doc_update/1, Docs);
+        {_, true} ->
+            lists:map(fun couch_users_db:before_doc_update/1, Docs);
+        _ ->
+            Docs
+    end.
+
+is_replicator_db(DbName) ->
+    ConfigName = list_to_binary(config:get("replicator", "db", "_replicator")),
+    DbName == ConfigName orelse path_ends_with(DbName, <<"_replicator">>).
+
+is_users_db(DbName) ->
+    ConfigName = list_to_binary(config:get(
+        "couch_httpd_auth", "authentication_db", "_users")),
+    DbName == ConfigName orelse path_ends_with(DbName, <<"_users">>).
+
+path_ends_with(Path, Suffix) ->
+    Suffix == lists:last(binary:split(mem3:dbname(Path), <<"/">>, [global])).
+
 tag_docs([]) ->
     [];
 tag_docs([#doc{meta=Meta}=Doc | Rest]) ->


[2/2] fabric commit: updated refs/heads/master to 9e87f8b

Posted by da...@apache.org.
Merge branch '2510-add-system-db-handlers'

Fixes #6


Project: http://git-wip-us.apache.org/repos/asf/couchdb-fabric/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-fabric/commit/9e87f8b3
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-fabric/tree/9e87f8b3
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-fabric/diff/9e87f8b3

Branch: refs/heads/master
Commit: 9e87f8b3fd827d322390fad2ab38f34f0a29858e
Parents: 5930256 4e0e81f
Author: Paul J. Davis <pa...@gmail.com>
Authored: Fri Dec 12 14:35:08 2014 -0600
Committer: Paul J. Davis <pa...@gmail.com>
Committed: Fri Dec 12 14:35:08 2014 -0600

----------------------------------------------------------------------
 src/fabric_doc_update.erl | 25 ++++++++++++++++++++++++-
 1 file changed, 24 insertions(+), 1 deletion(-)
----------------------------------------------------------------------