Skip to content

Instantly share code, notes, and snippets.

@tilgovi
Created September 16, 2010 21:42
Show Gist options
  • Save tilgovi/583223 to your computer and use it in GitHub Desktop.
Save tilgovi/583223 to your computer and use it in GitHub Desktop.
diff --git a/src/couchdb/couch_view.erl b/src/couchdb/couch_view.erl
index 35bc80b..2980370 100644
--- a/src/couchdb/couch_view.erl
+++ b/src/couchdb/couch_view.erl
@@ -96,13 +96,19 @@ cleanup_index_files(Db) ->
FileList = list_index_files(Db),
- % regex that matches all ddocs
- RegExp = "("++ string:join(Sigs, "|") ++")",
+ DeleteFiles =
+ case Sigs of
+ [] -> FileList;
+ _ ->
+ % 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"),
@tilgovi
Copy link
Author

tilgovi commented Sep 16, 2010

Still needs to catch the cases where you delete all the views but not the design doc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment