From b7e4a4409bd9f114011b6a7e970258d34a55996a Mon Sep 17 00:00:00 2001 From: ILYA Khlopotov Date: Wed, 7 Jan 2015 11:00:19 -0800 Subject: [PATCH] Modify init_delete_dir to be async In the case when .delete directory contains lots of files. The deletion of the directory leads to timeout in the supervisor. Which in it's turn kills the node. COUCHDB-2524 --- src/couch_file.erl | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/couch_file.erl b/src/couch_file.erl index 3ebf6083..1a47d2b8 100644 --- a/src/couch_file.erl +++ b/src/couch_file.erl @@ -260,10 +260,13 @@ init_delete_dir(RootDir) -> % note: ensure_dir requires an actual filename companent, which is the % reason for "foo". filelib:ensure_dir(filename:join(Dir,"foo")), - filelib:fold_files(Dir, ".*", true, - fun(Filename, _) -> - ok = file:delete(Filename) - end, ok). + spawn(fun() -> + filelib:fold_files(Dir, ".*", true, + fun(Filename, _) -> + ok = file:delete(Filename) + end, ok) + end), + ok. read_header(Fd) ->