Skip to content
This repository has been archived by the owner on Oct 22, 2021. It is now read-only.

Commit

Permalink
send checksum callback separately as range requests will not send one.
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert Newson committed Feb 17, 2011
1 parent 95bfacf commit 889e791
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/monic_file.erl
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,10 @@ handle_call({read, #handle{location=Location,cookie=Cookie}, Fun}, _From, #state
case read_item_footer(Fd, Location + ?ITEM_HEADER_SIZE + Len) of
{ok, #item_footer{sha=RecordedSha}} ->
case RecordedSha of
CalculatedSha -> Fun({eof, checksum_verified});
_ -> Fun({eof, checksum_failed})
CalculatedSha -> Fun({checksum, valid});
_ -> Fun({checksum, invalid})
end,
Fun(eof),
{reply, ok, State};
Else ->
{reply, {error, Else}, State}
Expand Down
4 changes: 3 additions & 1 deletion test/monic_test.erl
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ read_fun() ->
undefined ->
?assertEqual({ok, <<"foobar">>}, R);
{ok, <<"foobar">>} ->
?assertEqual({eof, checksum_verified}, R)
?assertEqual({checksum, valid}, R);
{checksum, valid} ->
?assertEqual(eof, R)
end,
put(last, R) end,
ok = monic:read("foo", Handle, Fun).
Expand Down

0 comments on commit 889e791

Please sign in to comment.