From 879657505328aca528f8bf7d0f50373ff11846d9 Mon Sep 17 00:00:00 2001 From: Kresten Krab Thorup Date: Mon, 23 Apr 2012 13:24:01 +0200 Subject: [PATCH] Fix dumb errors --- src/hanoi_util.erl | 2 +- src/hanoi_writer.erl | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/hanoi_util.erl b/src/hanoi_util.erl index ba8e4c0..c72ff50 100644 --- a/src/hanoi_util.erl +++ b/src/hanoi_util.erl @@ -62,7 +62,7 @@ encode_index_node(KVList, Compress) -> OutData = [?SNAPPY_COMPRESSION|Snappied] end; gzip -> - GZipData = zlib:gzip(TermData); + GZipData = zlib:gzip(TermData), if byte_size(GZipData) > byte_size(TermData) -> OutData = [?NO_COMPRESSION|TermData]; true -> diff --git a/src/hanoi_writer.erl b/src/hanoi_writer.erl index 50e6bea..a02bea2 100644 --- a/src/hanoi_writer.erl +++ b/src/hanoi_writer.erl @@ -190,9 +190,9 @@ close_node(#state{nodes=[#node{ level=Level, members=NodeMembers }|RestNodes], c {ok, BlockData} = hanoi_util:encode_index_node(OrderedMembers, Compress), NodePos = State#state.index_file_pos, - BlockSize = byte_size(BlockData), + BlockSize = erlang:iolist_size(BlockData), Data = [ <<(BlockSize+2):32/unsigned, Level:16/unsigned>> | BlockData ], - DataSize = BlockData + 6, + DataSize = BlockSize + 6, ok = file:write(State#state.index_file, Data),