Github user kxepal commented on a diff in the pull request:
https://github.com/apache/couchdb-couch/pull/27#discussion_r22122343
--- 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 --
May be log failures there? Otherwise, if file couldn't be deleted (say,
it's locked on Windows by antivirus process) then this function will constantly
crash because or rename about since TmpDir will still be existed.
---
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 [email protected] or file a JIRA ticket
with INFRA.
---