Skip to content

Commit d8274a0

Browse files
author
Simon MacMullen
committed
Backport b2eef0b1b7b5 (Merge of bug25021; Bug 24994 can cause log files to grow in size exponentially)
1 parent 57f8958 commit d8274a0

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/rabbit_file.erl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,24 @@ make_binary(List) ->
168168
{error, Reason}
169169
end.
170170

171+
%% TODO the semantics of this function are rather odd. But see bug 25021.
171172
append_file(File, Suffix) ->
173+
case read_file_info(File) of
174+
{ok, FInfo} -> append_file(File, FInfo#file_info.size, Suffix);
175+
{error, enoent} -> append_file(File, 0, Suffix);
176+
Error -> Error
177+
end.
178+
179+
append_file(_, _, "") ->
180+
ok;
181+
append_file(File, 0, Suffix) ->
182+
with_fhc_handle(fun () ->
183+
case prim_file:open([File, Suffix], [append]) of
184+
{ok, Fd} -> prim_file:close(Fd);
185+
Error -> Error
186+
end
187+
end);
188+
append_file(File, _, Suffix) ->
172189
case with_fhc_handle(2, fun () ->
173190
file:copy(File, {[File, Suffix], [append]})
174191
end) of

0 commit comments

Comments
 (0)