You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by rn...@apache.org on 2013/06/29 17:18:14 UTC

[33/50] [abbrv] git commit: updated refs/heads/1843-feature-bigcouch to cba2e81

[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/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/77e7a1ff
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/77e7a1ff
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/77e7a1ff

Branch: refs/heads/1843-feature-bigcouch
Commit: 77e7a1ffb62e32b55a2cfa02847682a8b386bd5f
Parents: 6e53c8a
Author: Paul J. Davis <pa...@gmail.com>
Authored: Wed Mar 13 02:36:33 2013 -0500
Committer: Paul J. Davis <pa...@gmail.com>
Committed: Wed Mar 20 06:02:55 2013 -0500

----------------------------------------------------------------------
 share/www/script/couch.js        | 2 +-
 src/couch/src/couch_httpd_db.erl | 6 +++++-
 src/couch/src/couch_server.erl   | 6 ++++--
 3 files changed, 10 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/77e7a1ff/share/www/script/couch.js
----------------------------------------------------------------------
diff --git a/share/www/script/couch.js b/share/www/script/couch.js
index 58ad7a7..122db75 100644
--- a/share/www/script/couch.js
+++ b/share/www/script/couch.js
@@ -36,7 +36,7 @@ function CouchDB(name, httpHeaders) {
 
   // Deletes the database on the server
   this.deleteDb = function() {
-    this.last_req = this.request("DELETE", this.uri);
+    this.last_req = this.request("DELETE", this.uri + "?sync=true");
     if (this.last_req.status == 404) {
       return false;
     }

http://git-wip-us.apache.org/repos/asf/couchdb/blob/77e7a1ff/src/couch/src/couch_httpd_db.erl
----------------------------------------------------------------------
diff --git a/src/couch/src/couch_httpd_db.erl b/src/couch/src/couch_httpd_db.erl
index c70245c..50fba6c 100644
--- a/src/couch/src/couch_httpd_db.erl
+++ b/src/couch/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/blob/77e7a1ff/src/couch/src/couch_server.erl
----------------------------------------------------------------------
diff --git a/src/couch/src/couch_server.erl b/src/couch/src/couch_server.erl
index c23ec05..3d4a1a6 100644
--- a/src/couch/src/couch_server.erl
+++ b/src/couch/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};