Repository: couchdb-chttpd
Updated Branches:
  refs/heads/master 129cdf934 -> 994f132fd


add clusterwide compaction for dbs

PRs:
https://github.com/apache/couchdb-chttpd/pull/62
https://github.com/apache/couchdb-fabric/pull/27

COUCHDB-2492

PR: #62
PR-URL: https://github.com/apache/couchdb-chttpd/pull/62
Reviewed-By: Robert Newson <rnew...@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/commit/994f132f
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/tree/994f132f
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/diff/994f132f

Branch: refs/heads/master
Commit: 994f132fd0923223ec7fd0802288fc2814bcc634
Parents: 129cdf9
Author: Robert Kowalski <robertkowal...@apache.org>
Authored: Fri Aug 21 14:13:18 2015 +0200
Committer: Robert Kowalski <robertkowal...@apache.org>
Committed: Thu Aug 27 15:50:09 2015 +0200

----------------------------------------------------------------------
 src/chttpd_db.erl | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/blob/994f132f/src/chttpd_db.erl
----------------------------------------------------------------------
diff --git a/src/chttpd_db.erl b/src/chttpd_db.erl
index 89e3a88..9b064ce 100644
--- a/src/chttpd_db.erl
+++ b/src/chttpd_db.erl
@@ -225,9 +225,20 @@ maybe_flush_changes_feed(Acc0, Data, Len) ->
     },
     {ok, Acc}.
 
-handle_compact_req(Req, _) ->
-    Msg = <<"Compaction must be triggered on a per-shard basis in CouchDB">>,
-    couch_httpd:send_error(Req, 403, forbidden, Msg).
+handle_compact_req(#httpd{method='POST', path_parts=[_DbName, <<"_compact">>, 
_DesignName | _]}=Req, _Db) ->
+    Msg = <<"Compactions for views must be triggered on a per-shard basis in 
CouchDB">>,
+    couch_httpd:send_error(Req, 403, forbidden, Msg);
+
+handle_compact_req(#httpd{method='POST', path_parts=[_DbName, 
<<"_compact">>]}=Req, Db) ->
+    couch_httpd:validate_ctype(Req, "application/json"),
+    ok = couch_db:check_is_admin(Db),
+    couch_httpd:body(Req),
+    fabric:compact_db(Db#db.name),
+    send_json(Req, 202, {[{ok, true}]});
+
+handle_compact_req(Req, _Db) ->
+    send_method_not_allowed(Req, "POST").
+
 
 handle_view_cleanup_req(Req, Db) ->
     ok = fabric:cleanup_index_files(Db),

Reply via email to