diff --git a/src/hanoidb_nursery.erl b/src/hanoidb_nursery.erl index d670961..dfb7fcd 100644 --- a/src/hanoidb_nursery.erl +++ b/src/hanoidb_nursery.erl @@ -246,8 +246,8 @@ add(Key, Value, Expiry, Nursery, Top) -> case do_add(Nursery, Key, Value, Expiry, Top) of {ok, Nursery0} -> {ok, Nursery0}; - {full, Nursery1} -> - flush(Nursery1, Top) + {full, Nursery0} -> + flush(Nursery0, Top) end. flush(Nursery=#nursery{ dir=Dir, max_level=MaxLevel, config=Config }, Top) -> diff --git a/src/hanoidb_writer.erl b/src/hanoidb_writer.erl index becccc1..12c9720 100644 --- a/src/hanoidb_writer.erl +++ b/src/hanoidb_writer.erl @@ -186,15 +186,12 @@ do_open(Name, Options, OpenOpts) -> %% @doc flush pending nodes and write trailer -flush_nodes(State=#state{ nodes=[#node{level=N, members=[{_,{Pos,_Len}}]}], last_node_pos=Pos }) when N>0 -> - %% stack consists of one node with one {pos,len} member. Just ignore this node. - flush_nodes(State#state{ nodes=[] }); flush_nodes(#state{ nodes=[], last_node_pos=LastNodePos, last_node_size=_LastNodeSize, bloom=Bloom }=State) -> IdxFile = State#state.index_file, RootPos = - case LastNodePos of - undefined -> + case LastNodePos =:= undefined of + true -> %% store contains no entries ok = file:write(IdxFile, <<0:32,0:16>>), ?FIRST_BLOCK_POS;