You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ko...@apache.org on 2017/03/01 16:37:40 UTC

[06/43] couch-mrview commit: updated refs/heads/2971-count-distinct to f7c3c24

Use couch_file:delete/3 in views cleanup


Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/commit/7293bfb6
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/tree/7293bfb6
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/diff/7293bfb6

Branch: refs/heads/2971-count-distinct
Commit: 7293bfb64041d6bb1243ecc8c3ddd71d02811294
Parents: 56b66b4
Author: Eric Avdey <ei...@eiri.ca>
Authored: Wed Apr 20 14:55:52 2016 -0300
Committer: Eric Avdey <ei...@eiri.ca>
Committed: Thu Apr 28 14:08:00 2016 -0300

----------------------------------------------------------------------
 src/couch_mrview_cleanup.erl | 66 +--------------------------------------
 1 file changed, 1 insertion(+), 65 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/blob/7293bfb6/src/couch_mrview_cleanup.erl
----------------------------------------------------------------------
diff --git a/src/couch_mrview_cleanup.erl b/src/couch_mrview_cleanup.erl
index b96622a..380376d 100644
--- a/src/couch_mrview_cleanup.erl
+++ b/src/couch_mrview_cleanup.erl
@@ -41,71 +41,7 @@ run(Db) ->
 
     lists:foreach(fun(FN) ->
         couch_log:debug("Deleting stale view file: ~s", [FN]),
-        delete_view_file(RootDir, FN)
+        couch_file:delete(RootDir, FN, [sync])
     end, ToDelete),
 
     ok.
-
-delete_view_file(RootDir, FullFilePath) ->
-    couch_server:delete_file(RootDir, FullFilePath, [sync]).
-
--ifdef(TEST).
--include_lib("couch/include/couch_eunit.hrl").
-
-setup(rename) ->
-    setup(true);
-setup(delete) ->
-    setup(false);
-setup(RenameOnDelete) ->
-    meck:new(config, [passthrough]),
-    meck:expect(config, get_boolean, fun
-        ("couchdb", "rename_on_delete", _Default) -> RenameOnDelete
-    end),
-    ViewFile = ?tempfile() ++ ".view",
-    RootDir = filename:dirname(ViewFile),
-    ok = couch_file:init_delete_dir(RootDir),
-    ok = file:write_file(ViewFile, <<>>),
-    {RootDir, ViewFile}.
-
-teardown(_, {_, ViewFile}) ->
-    (catch meck:unload(config)),
-    (catch file:delete(ViewFile)).
-
-delete_view_file_test_() ->
-    Funs = [
-        fun should_rename_on_delete/2,
-        fun should_delete/2
-    ],
-    [
-        make_test_case(rename, [fun should_rename_on_delete/2]),
-        make_test_case(delete, [fun should_delete/2])
-    ].
-
-make_test_case(Mod, Funs) ->
-    {
-        lists:flatten(io_lib:format("~s", [Mod])),
-        {foreachx, fun setup/1, fun teardown/2, [{Mod, Fun} || Fun <- Funs]}
-    }.
-
-should_rename_on_delete(_, {RootDir, ViewFile}) ->
-    ?_test(begin
-        ?assert(filelib:is_regular(ViewFile)),
-        Result = delete_view_file(RootDir, ViewFile),
-        ?assertNot(filelib:is_regular(ViewFile)),
-        ?assertMatch({ok, {renamed, _}}, Result),
-        {ok, {renamed, RenamedViewFile}} = Result,
-        ?assert(filelib:is_regular(RenamedViewFile))
-    end).
-
-should_delete(_, {RootDir, ViewFile}) ->
-    ?_test(begin
-        ?assert(filelib:is_regular(ViewFile)),
-        delete_view_file(RootDir, ViewFile),
-        ?assertNot(filelib:is_regular(ViewFile)),
-        ?assertMatch([], deleted_files(ViewFile))
-    end).
-
-deleted_files(ViewFile) ->
-    filelib:wildcard(filename:rootname(ViewFile) ++ "*.deleted.*").
-
--endif.