diff options
author | Damien F. Katz <damien@apache.org> | 2008-08-07 20:28:42 +0000 |
---|---|---|
committer | Damien F. Katz <damien@apache.org> | 2008-08-07 20:28:42 +0000 |
commit | 986302c54df1bdb4be3dc1d1a4d5a9f34e6af50d (patch) | |
tree | 6f9d1caef3dc1b619999890a0e364961c88f2992 | |
parent | d721ef270cf548e2d217c471da44d0c31054ed98 (diff) |
Fix for bug COUCHDB-100.
git-svn-id: https://svn.apache.org/repos/asf/incubator/couchdb/trunk@683704 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | share/www/script/couch_tests.js | 4 | ||||
-rw-r--r-- | src/couchdb/couch_db.erl | 2 | ||||
-rw-r--r-- | src/couchdb/couch_httpd.erl | 16 |
3 files changed, 15 insertions, 7 deletions
diff --git a/share/www/script/couch_tests.js b/share/www/script/couch_tests.js index 0308ed8d..32a53909 100644 --- a/share/www/script/couch_tests.js +++ b/share/www/script/couch_tests.js @@ -16,6 +16,10 @@ var tests = { 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; diff --git a/src/couchdb/couch_db.erl b/src/couchdb/couch_db.erl index 098f3de7..e8c7eb93 100644 --- a/src/couchdb/couch_db.erl +++ b/src/couchdb/couch_db.erl @@ -44,7 +44,7 @@ start_link0(DbName, Filepath, Options) -> ok = file:rename(Filepath ++ ".compact", Filepath), Fd0; {error, enoent} -> - throw({error, not_found}) + throw(not_found) end; Else -> throw(Else) diff --git a/src/couchdb/couch_httpd.erl b/src/couchdb/couch_httpd.erl index 86e41f8b..85fbe868 100644 --- a/src/couchdb/couch_httpd.erl +++ b/src/couchdb/couch_httpd.erl @@ -168,6 +168,16 @@ handle_db_request(Req, 'PUT', {DbName, []}) -> 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 @@ handle_db_request(Req, Method, {DbName, Rest}) -> 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]}); |