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/02/10 21:22:52 UTC

[30/50] couch commit: updated refs/heads/import to 09c6556

[review] Delete dbs synchronously

For the test suite this should minimize the "file exists" errors that we
see. Theoretically maybe.


Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch/commit/68d60f07
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch/tree/68d60f07
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch/diff/68d60f07

Branch: refs/heads/import
Commit: 68d60f073270bef6d95b2be6ecfd9ccd472bd78a
Parents: 1a8d72c
Author: Paul J. Davis <pa...@gmail.com>
Authored: Wed Mar 13 02:36:33 2013 -0500
Committer: Paul J. Davis <pa...@gmail.com>
Committed: Tue Feb 4 17:03:25 2014 -0600

----------------------------------------------------------------------
 src/couch_httpd_db.erl | 6 +++++-
 src/couch_server.erl   | 6 ++++--
 2 files changed, 9 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/68d60f07/src/couch_httpd_db.erl
----------------------------------------------------------------------
diff --git a/src/couch_httpd_db.erl b/src/couch_httpd_db.erl
index c70245c..50fba6c 100644
--- a/src/couch_httpd_db.erl
+++ b/src/couch_httpd_db.erl
@@ -220,7 +220,11 @@ create_db_req(#httpd{user_ctx=UserCtx}=Req, DbName) ->
 
 delete_db_req(#httpd{user_ctx=UserCtx}=Req, DbName) ->
     ok = couch_httpd:verify_is_server_admin(Req),
-    case couch_server:delete(DbName, [{user_ctx, UserCtx}]) of
+    Options = case couch_httpd:qs_value(Req, "sync") of
+        "true" -> [sync, {user_ctx, UserCtx}];
+        _ -> [{user_ctx, UserCtx}]
+    end,
+    case couch_server:delete(DbName, Options) of
     ok ->
         send_json(Req, 200, {[{ok, true}]});
     Error ->

http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/68d60f07/src/couch_server.erl
----------------------------------------------------------------------
diff --git a/src/couch_server.erl b/src/couch_server.erl
index c23ec05..3d4a1a6 100644
--- a/src/couch_server.erl
+++ b/src/couch_server.erl
@@ -408,7 +408,7 @@ handle_call({create, DbName, Options}, From, Server) ->
     Error ->
         {reply, Error, Server}
     end;
-handle_call({delete, DbName, _Options}, _From, Server) ->
+handle_call({delete, DbName, Options}, _From, Server) ->
     DbNameList = binary_to_list(DbName),
     case check_dbname(Server, DbNameList) of
     ok ->
@@ -436,7 +436,9 @@ handle_call({delete, DbName, _Options}, _From, Server) ->
         end, [".compact", ".compact.data", ".compact.meta"]),
         couch_file:delete(Server#server.root_dir, FullFilepath ++ ".compact"),
 
-        case couch_file:delete(Server#server.root_dir, FullFilepath) of
+        Async = not lists:member(sync, Options),
+
+        case couch_file:delete(Server#server.root_dir, FullFilepath, Async) of
         ok ->
             couch_db_update_notifier:notify({deleted, DbName}),
             {reply, ok, Server2};