diff options
author | Hubert Plociniczak <hubert@lshift.net> | 2008-08-28 11:26:42 +0100 |
---|---|---|
committer | Hubert Plociniczak <hubert@lshift.net> | 2008-08-28 11:26:42 +0100 |
commit | 2c7abca856ba0a09170e47049929677c13a1649f (patch) | |
tree | 9e11f72670cf0db81a505bcaa9e91f9170961a9b /src/rabbit_misc.erl | |
parent | 5d081a3aefadbe1650cb8b10169a4553dcec3bd7 (diff) | |
download | rabbitmq-server-2c7abca856ba0a09170e47049929677c13a1649f.tar.gz |
Create suffix file even when the original
one is empty or doesn't exist.
Diffstat (limited to 'src/rabbit_misc.erl')
-rw-r--r-- | src/rabbit_misc.erl | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/rabbit_misc.erl b/src/rabbit_misc.erl index 9dba775e..cf6a483a 100644 --- a/src/rabbit_misc.erl +++ b/src/rabbit_misc.erl @@ -341,14 +341,17 @@ dirty_dump_log1(LH, {K, Terms, BadBytes}) -> append_file(File, Suffix) -> case catch file:read_file_info(File) of {ok, FInfo} -> append_file(File, FInfo#file_info.size, Suffix); - {error, enoent} -> ok; + {error, enoent} -> append_file(File, 0, Suffix); Error -> Error end. -append_file(_, 0, _) -> - ok; append_file(_, _, "") -> ok; +append_file(File, 0, Suffix) -> + case file:open([File, Suffix], [append]) of + {ok, Fd} -> file:close(Fd); + Error -> Error + end; append_file(File, _, Suffix) -> case file:read_file(File) of {ok, Data} -> file:write_file([File, Suffix], Data, [append]); |