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 2008/08/07 22:28:43 UTC

svn commit: r683704 - in /incubator/couchdb/trunk: share/www/script/couch_tests.js src/couchdb/couch_db.erl src/couchdb/couch_httpd.erl

Author: damien
Date: Thu Aug  7 13:28:42 2008
New Revision: 683704

URL: http://svn.apache.org/viewvc?rev=683704&view=rev
Log:
Fix for bug COUCHDB-100.

Modified:
    incubator/couchdb/trunk/share/www/script/couch_tests.js
    incubator/couchdb/trunk/src/couchdb/couch_db.erl
    incubator/couchdb/trunk/src/couchdb/couch_httpd.erl

Modified: incubator/couchdb/trunk/share/www/script/couch_tests.js
URL: http://svn.apache.org/viewvc/incubator/couchdb/trunk/share/www/script/couch_tests.js?rev=683704&r1=683703&r2=683704&view=diff
==============================================================================
--- incubator/couchdb/trunk/share/www/script/couch_tests.js [utf-8] (original)
+++ incubator/couchdb/trunk/share/www/script/couch_tests.js [utf-8] Thu Aug  7 13:28:42 2008
@@ -16,6 +16,10 @@
   basics: function(debug) {
     var db = new CouchDB("test_suite_db");
     db.deleteDb();
+
+    // bug COUCHDB-100: DELETE on non-existent DB returns 500 instead of 404
+    db.deleteDb();
+    
     db.createDb();
     if (debug) debugger;
 

Modified: incubator/couchdb/trunk/src/couchdb/couch_db.erl
URL: http://svn.apache.org/viewvc/incubator/couchdb/trunk/src/couchdb/couch_db.erl?rev=683704&r1=683703&r2=683704&view=diff
==============================================================================
--- incubator/couchdb/trunk/src/couchdb/couch_db.erl (original)
+++ incubator/couchdb/trunk/src/couchdb/couch_db.erl Thu Aug  7 13:28:42 2008
@@ -44,7 +44,7 @@
             ok = file:rename(Filepath ++ ".compact", Filepath),
             Fd0;
         {error, enoent} ->
-            throw({error, not_found})
+            throw(not_found)
         end;
     Else ->
         throw(Else)

Modified: incubator/couchdb/trunk/src/couchdb/couch_httpd.erl
URL: http://svn.apache.org/viewvc/incubator/couchdb/trunk/src/couchdb/couch_httpd.erl?rev=683704&r1=683703&r2=683704&view=diff
==============================================================================
--- incubator/couchdb/trunk/src/couchdb/couch_httpd.erl (original)
+++ incubator/couchdb/trunk/src/couchdb/couch_httpd.erl Thu Aug  7 13:28:42 2008
@@ -168,6 +168,16 @@
             throw({unknown_error, Msg})
     end;
 
+handle_db_request(Req, 'DELETE', {DbName, []}) ->
+    case couch_server:delete(DbName) of
+    ok ->
+        send_json(Req, 200, {obj, [
+            {ok, true}
+        ]});
+    Error ->
+        throw(Error)
+    end;
+    
 handle_db_request(Req, Method, {DbName, Rest}) ->
     case couch_db:open(DbName, []) of
         {ok, Db} ->
@@ -180,12 +190,6 @@
             throw(Error)
     end;
 
-handle_db_request(Req, 'DELETE', {DbName, _Db, []}) ->
-    ok = couch_server:delete(DbName),
-    send_json(Req, 200, {obj, [
-        {ok, true}
-    ]});
-
 handle_db_request(Req, 'GET', {DbName, Db, []}) ->
     {ok, DbInfo} = couch_db:get_db_info(Db),
     send_json(Req, {obj, [{db_name, DbName} | DbInfo]});