Github user iilyak commented on a diff in the pull request: https://github.com/apache/couchdb-couch/pull/27#discussion_r22132403 --- Diff: src/couch_file.erl --- @@ -260,10 +260,19 @@ 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). + TmpDir = Dir ++ ".tmp", + % rename original directory so we can return and delete files asynchronously + ok = file:rename(Dir, TmpDir), + % recreate original directory + filelib:ensure_dir(filename:join(Dir,"foo")), + spawn(fun() -> + filelib:fold_files(TmpDir, ".*", true, + fun(Filename, _) -> + ok = file:delete(Filename) --- End diff -- Hmm very good point. Maybe I should use random suffix. And remove files in every directory with given prefix. I.e. ".delete.tmp.*"
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---