couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rnew...@apache.org
Subject svn commit: r1160620 - /couchdb/trunk/src/couchdb/couch_auth_cache.erl
Date Tue, 23 Aug 2011 11:01:20 GMT
Author: rnewson
Date: Tue Aug 23 11:01:20 2011
New Revision: 1160620

URL: http://svn.apache.org/viewvc?rev=1160620&view=rev
Log:
auto-upgrade /_users/_design/_auth if validate fun fails to match.

Modified:
    couchdb/trunk/src/couchdb/couch_auth_cache.erl

Modified: couchdb/trunk/src/couchdb/couch_auth_cache.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_auth_cache.erl?rev=1160620&r1=1160619&r2=1160620&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_auth_cache.erl (original)
+++ couchdb/trunk/src/couchdb/couch_auth_cache.erl Tue Aug 23 11:01:20 2011
@@ -392,8 +392,17 @@ ensure_auth_ddoc_exists(Db, DDocId) ->
     {not_found, _Reason} ->
         {ok, AuthDesign} = auth_design_doc(DDocId),
         {ok, _Rev} = couch_db:update_doc(Db, AuthDesign, []);
-    _ ->
-        ok
+    {ok, Doc} ->
+        {Props} = couch_doc:to_json_obj(Doc, []),
+        case couch_util:get_value(<<"validate_doc_update">>, Props, []) of
+            ?AUTH_DB_DOC_VALIDATE_FUNCTION ->
+                ok;
+            _ ->
+                Props1 = lists:keyreplace(<<"validate_doc_update">>, 1, Props,
+                    {<<"validate_doc_update">>,
+                    ?AUTH_DB_DOC_VALIDATE_FUNCTION}),
+                couch_db:update_doc(Db, couch_doc:from_json_obj({Props1}), [])
+        end
     end,
     ok.
 



Mime
View raw message