Merge remote-tracking branch 'cloudant/2779-view-cleanup-cluster-aware'
Project: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/commit/663273b0 Tree: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/tree/663273b0 Diff: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/diff/663273b0 Branch: refs/heads/master Commit: 663273b0ed2ea4eae16d9d36e1922138fb25e766 Parents: 68f8fa5 f0f4c0d Author: Robert Newson <[email protected]> Authored: Thu Aug 11 12:28:05 2016 +0100 Committer: Robert Newson <[email protected]> Committed: Thu Aug 11 12:28:05 2016 +0100 ---------------------------------------------------------------------- src/chttpd_db.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/blob/663273b0/src/chttpd_db.erl ---------------------------------------------------------------------- diff --cc src/chttpd_db.erl index 7f0dce7,f5a3176..fbf59ef --- a/src/chttpd_db.erl +++ b/src/chttpd_db.erl @@@ -225,27 -225,12 +225,27 @@@ maybe_flush_changes_feed(Acc0, Data, Le }, {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'}=Req, Db) -> + chttpd:validate_ctype(Req, "application/json"), + case Req#httpd.path_parts of + [_DbName, <<"_compact">>] -> + ok = fabric:compact(Db), + send_json(Req, 202, {[{ok, true}]}); + [DbName, <<"_compact">>, DesignName | _] -> + case ddoc_cache:open(DbName, <<"_design/", DesignName/binary>>) of + {ok, _DDoc} -> + ok = fabric:compact(Db, DesignName), + send_json(Req, 202, {[{ok, true}]}); + Error -> + throw(Error) + end + end; + +handle_compact_req(Req, _Db) -> + send_method_not_allowed(Req, "POST"). handle_view_cleanup_req(Req, Db) -> - ok = fabric:cleanup_index_files(Db), + ok = fabric:cleanup_index_files_all_nodes(Db), send_json(Req, 202, {[{ok, true}]}). handle_design_req(#httpd{
