Skip to content

Commit

Permalink
offset issue was causing aligned sub-blocksize appends to duplicate t…
Browse files Browse the repository at this point in the history
…he previous last block on the file
  • Loading branch information
Cliff Moon committed Jul 10, 2010
1 parent 9c09baa commit 553e500
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/luwak_io.erl
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ no_tree_put_range(Riak, File, Start, Data) ->
write_blocks(Riak, File, undefined, Start, Data, BlockSize, []);
_BlockOffset ->
?debugFmt("blockoffset ~p~n", [_BlockOffset]),
{ok, Block} = luwak_tree:block_at(Riak, File, Start),
{ok, Block} = luwak_tree:block_at(Riak, File, Start-_BlockOffset),
write_blocks(Riak, File, Block, Start, Data, BlockSize, [])
end.

Expand All @@ -79,7 +79,7 @@ internal_put_range(Riak, File, Start, Data) ->
fun() -> crypto:sha(Data) end),
{ok, Written, NewFile1};
_BlockOffset ->
{ok, Block} = luwak_tree:block_at(Riak, File, Start),
{ok, Block} = luwak_tree:block_at(Riak, File, Start-_BlockOffset),
{ok, Written} =
write_blocks(Riak, File, Block, Start, Data, BlockSize, []),
{ok, NewFile} =
Expand Down
2 changes: 1 addition & 1 deletion src/luwak_tree.erl
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ block_at_node(_Riak, NodeObj, block, _, _NodeOffset, _) ->
{ok, NodeObj}.

which_child([E={_ChildName,Length}], NodeOffset, Pos, Acc)
when Pos > Length+NodeOffset ->
when Pos >= Length+NodeOffset ->
?debugFmt("A which_child(~p, ~p, ~p)~n", [E, NodeOffset, Pos]),
{lists:reverse([E|Acc]), undefined, []};
which_child([E], _NodeOffset, _Pos, Acc) ->
Expand Down

0 comments on commit 553e500

Please sign in to comment.