Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixes for reading old 09 files.

git-svn-id: https://svn.apache.org/repos/asf/couchdb/branches/tail_header@777345 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information...
commit 2a269ac190e941e5879cc70b276dada008b85dcc 1 parent 509780e
Damien F. Katz authored
Showing with 5 additions and 6 deletions.
  1. +1 −1  src/couchdb/couch_db_updater.erl
  2. +4 −5 src/couchdb/couch_file.erl
View
2  src/couchdb/couch_db_updater.erl
@@ -56,7 +56,7 @@ handle_call({update_docs, DocActions, Options}, _From, Db) ->
end;
handle_call(full_commit, _From, #db{waiting_delayed_commit=nil}=Db) ->
{reply, ok, Db}; % no data waiting, return ok immediately
-handle_call(full_commit, _From, #db{fd=Fd}=Db) ->
+handle_call(full_commit, _From, Db) ->
{reply, ok, commit_data(Db)}; % commit the data and return ok
handle_call(increment_update_seq, _From, Db) ->
Db2 = commit_data(Db#db{update_seq=Db#db.update_seq+1}),
View
9 src/couchdb/couch_file.erl
@@ -66,7 +66,7 @@ open(Filepath, Options) ->
%%----------------------------------------------------------------------
append_term(Fd, Term) ->
- append_binary(Fd, term_to_binary(Term, [compressed])).
+ append_binary(Fd, term_to_binary(Term)).
%%----------------------------------------------------------------------
@@ -112,8 +112,6 @@ pread_iolist(Fd, Pos) ->
{ok, Iolist, _} = read_raw_iolist(Fd, NextPos, Len),
{ok, Iolist}.
-read_raw_iolist(Fd, Pos, Len) when (Pos rem ?SIZE_BLOCK) == 0 ->
- read_raw_iolist(Fd, Pos + 1, Len);
read_raw_iolist(Fd, Pos, Len) ->
BlockOffset = Pos rem ?SIZE_BLOCK,
TotalBytes = calculate_total_read_len(BlockOffset, Len),
@@ -249,7 +247,7 @@ terminate(_Reason, _Fd) ->
handle_call({pread, Pos, Bytes}, _From, #file{fd=Fd,tail_append_begin=TailAppendBegin}=File) ->
{ok, Bin} = file:pread(Fd, Pos, Bytes),
- {reply, {ok, Bin, Pos > TailAppendBegin}, File};
+ {reply, {ok, Bin, Pos >= TailAppendBegin}, File};
handle_call(bytes, _From, #file{fd=Fd}=File) ->
{reply, file:position(Fd, eof), File};
handle_call(sync, _From, #file{fd=Fd}=File) ->
@@ -436,7 +434,8 @@ load_header(Fd, Block) ->
Md5Sig = erlang:md5(HeaderBin),
{ok, HeaderBin}.
-
+calculate_total_read_len(0, FinalLen) ->
+ calculate_total_read_len(1, FinalLen) + 1;
calculate_total_read_len(BlockOffset, FinalLen) ->
case ?SIZE_BLOCK - BlockOffset of
BlockLeft when BlockLeft >= FinalLen ->
Please sign in to comment.
Something went wrong with that request. Please try again.