diff options
| author | Emile Joubert <emile@rabbitmq.com> | 2012-06-22 16:51:20 +0100 |
|---|---|---|
| committer | Emile Joubert <emile@rabbitmq.com> | 2012-06-22 16:51:20 +0100 |
| commit | d458ae08cab606f12beebc553b9e8d833638673b (patch) | |
| tree | 18f526f6324d699374cf50b44ddd17943e13f0e0 | |
| parent | 2c16b335187f117ba454b2ea70adfad64b5b0b77 (diff) | |
| parent | 3b78387ae18fc083856534919aee61becbbcbc2e (diff) | |
| download | rabbitmq-server-git-d458ae08cab606f12beebc553b9e8d833638673b.tar.gz | |
Merged bug25021 into default
| -rw-r--r-- | src/rabbit_file.erl | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/rabbit_file.erl b/src/rabbit_file.erl index 5937a335b5..a95f8f269d 100644 --- a/src/rabbit_file.erl +++ b/src/rabbit_file.erl @@ -168,7 +168,24 @@ make_binary(List) -> {error, Reason} end. +%% TODO the semantics of this function are rather odd. But see bug 25021. append_file(File, Suffix) -> + case read_file_info(File) of + {ok, FInfo} -> append_file(File, FInfo#file_info.size, Suffix); + {error, enoent} -> append_file(File, 0, Suffix); + Error -> Error + end. + +append_file(_, _, "") -> + ok; +append_file(File, 0, Suffix) -> + with_fhc_handle(fun () -> + case prim_file:open([File, Suffix], [append]) of + {ok, Fd} -> prim_file:close(Fd); + Error -> Error + end + end); +append_file(File, _, Suffix) -> case with_fhc_handle(2, fun () -> file:copy(File, {[File, Suffix], [append]}) end) of |
