summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon MacMullen <simon@rabbitmq.com>2012-06-22 16:20:04 +0100
committerSimon MacMullen <simon@rabbitmq.com>2012-06-22 16:20:04 +0100
commit1a89d54582628a4a42daf89dac3256e3af17099c (patch)
tree2c23ac8f8a58aa7cf2a81dbaacb9d390dbdb3241
parent68d089fd3763d762e23121a15aafcdc4174f5577 (diff)
downloadrabbitmq-server-bug25021.tar.gz
Revert the wrapper around the copy in append_file/2bug25021
-rw-r--r--src/rabbit_file.erl17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/rabbit_file.erl b/src/rabbit_file.erl
index 5937a335..a95f8f26 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