From b1243f897fe4ac5d0719bec464c14d00b72875d9 Mon Sep 17 00:00:00 2001 From: Paul Joseph Davis Date: Thu, 23 Jul 2009 13:01:26 +0000 Subject: Fixes etap tests for recent updates. Thanks Bob Dionne git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@797053 13f79535-47bb-0310-9956-ffa450edef68 --- src/couchdb/couch_file.erl | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/couchdb/couch_file.erl b/src/couchdb/couch_file.erl index e8b37aa5..2dfc5403 100644 --- a/src/couchdb/couch_file.erl +++ b/src/couchdb/couch_file.erl @@ -116,26 +116,23 @@ pread_binary(Fd, Pos) -> {ok, L} = pread_iolist(Fd, Pos), {ok, iolist_to_binary(L)}. + pread_iolist(Fd, Pos) -> - {ok, LenIolist, NextPos} =read_raw_iolist(Fd, Pos, 20), + {ok, LenIolist, NextPos} = read_raw_iolist(Fd, Pos, 4), case iolist_to_binary(LenIolist) of - <<1:1/integer,Len:31/integer,Md5/binary>> -> - {ok, Iolist, _} = read_raw_iolist(Fd, NextPos, Len), - case erlang:md5(Iolist) of + <<1:1/integer,Len:31/integer>> -> + {ok, Md5List, ValPos} = read_raw_iolist(Fd, NextPos, 16), + Md5 = iolist_to_binary(Md5List), + {ok, IoList, _} = read_raw_iolist(Fd,ValPos,Len), + case erlang:md5(IoList) of Md5 -> ok; _ -> throw(file_corruption) end, - {ok, Iolist}; - <<0:1/integer,Len:31/integer,First16Bytes/binary>> -> - if Len =< 16 -> - <> = First16Bytes, - {ok, Final}; - true -> - {ok, Iolist, _} = read_raw_iolist(Fd, NextPos, Len - 16), - {ok, [First16Bytes, Iolist]} - end + {ok, IoList}; + <<0:1/integer,Len:31/integer>> -> + {ok, Iolist, _} = read_raw_iolist(Fd, NextPos, Len), + {ok, Iolist} end. - read_raw_iolist(Fd, Pos, Len) -> -- cgit v1.2.3