From 218f61ca2844ef4326157c6db958574c29c1ea40 Mon Sep 17 00:00:00 2001 From: Randall Leeds Date: Wed, 8 Jun 2011 18:57:43 +0000 Subject: backport r1133312 from trunk _view_cleanup with no _design docs - COUCHDB-1136 git-svn-id: https://svn.apache.org/repos/asf/couchdb/branches/1.1.x@1133510 13f79535-47bb-0310-9956-ffa450edef68 --- src/couchdb/couch_view.erl | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'src/couchdb') diff --git a/src/couchdb/couch_view.erl b/src/couchdb/couch_view.erl index 911f1aa6..c9a9b2cc 100644 --- a/src/couchdb/couch_view.erl +++ b/src/couchdb/couch_view.erl @@ -92,13 +92,18 @@ cleanup_index_files(Db) -> FileList = list_index_files(Db), - % regex that matches all ddocs - RegExp = "("++ string:join(Sigs, "|") ++")", + DeleteFiles = + if length(Sigs) =:= 0 -> + FileList; + true -> + % regex that matches all ddocs + RegExp = "("++ string:join(Sigs, "|") ++")", + + % filter out the ones in use + [FilePath || FilePath <- FileList, + re:run(FilePath, RegExp, [{capture, none}]) =:= nomatch] + end, - % filter out the ones in use - DeleteFiles = [FilePath - || FilePath <- FileList, - re:run(FilePath, RegExp, [{capture, none}]) =:= nomatch], % delete unused files ?LOG_DEBUG("deleting unused view index files: ~p",[DeleteFiles]), RootDir = couch_config:get("couchdb", "view_index_dir"), -- cgit v1.2.3