Github user eiri commented on a diff in the pull request:

    https://github.com/apache/couchdb-couch/pull/161#discussion_r59075768
  
    --- Diff: src/couch_file.erl ---
    @@ -253,14 +253,23 @@ deleted_filename_suffix() ->
             [Y, Mon, D, H, Min, S, couch_uuids:random()]).
     
     nuke_dir(RootDelDir, Dir) ->
    +    case config:get_boolean("couchdb", "rename_on_delete", false) of
    +        true -> couch_server:delete_file(RootDelDir, Dir, []);
    +        false -> delete_dir(RootDelDir, Dir)
    +    end.
    +
    +delete_dir(RootDelDir, Dir) ->
         FoldFun = fun(File) ->
             Path = Dir ++ "/" ++ File,
             case filelib:is_dir(Path) of
                 true ->
    -                ok = nuke_dir(RootDelDir, Path),
    +                ok = delete_dir(RootDelDir, Path),
                     file:del_dir(Path);
                 false ->
    -                delete(RootDelDir, Path, false)
    +                UUID = couch_uuids:random(),
    +                DelFile = filename:join([RootDelDir, ".delete", UUID]),
    +                file:rename(Path, DelFile),
    +                file:delete(DelFile)
    --- End diff --
    
    I believe this is a performance thing related to Windows fs, that why 
`couch_file:delete/3` does the same thing - renames and then deletes. Since it 
was called here previously with `sync`, I'm mimic it, but with simplified 
renaming approach to avoid taxing calls for `config`, `calendar` and 
`url_encode`.


---
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.
---

Reply via email to