anchor.diff:          end,
           Parent ! {writer_checkpoint, HighSeq},
           couch_rep_att:cleanup(),
  +        couch_util:should_flush(),
           writer_loop(Parent, Reader, Target)
       end.
   
  
positive.code:     Size = size(Data),
      {Size, [ibrowse_lib:dec2hex(8, Size), "\r\n", Data, "\r\n"]}.
  
  upload_docs({start, Docs}) ->
      {Size, Chunk} = make_chunk(<<"{\"new_edits\":false, \"docs\":[">>),
      {ok, Chunk, {continue, Docs, "", Size}};
  upload_docs({continue, Docs, _, ByteCount}) when ByteCount > ?MAX_BYTES ->
      put(docs_remaining, Docs),
      {ok, "2\r\n]}\r\n", last_chunk};
  upload_docs({continue, [Doc|Rest], Prepend, ByteCount}) ->
      JsonDoc = ?JSON_ENCODE(couch_doc:to_json_obj(Doc, [revs,attachments])),
      {Size, Chunk} = make_chunk([Prepend, JsonDoc]),
      {ok, Chunk, {continue, Rest, ",", ByteCount+Size}};
  upload_docs({continue, [], _, _}) ->
      {ok, "2\r\n]}\r\n", last_chunk};
  upload_docs(last_chunk) ->
      {ok, "0\r\n\r\n", finish};
  upload_docs(finish) ->
      eof.
      
  writer_loop(Parent, Reader, Target) ->
  
negative.code:             Reason = proplists:get_value(<<"reason">>, Props),
              {{Id, Rev}, {ErrId, Reason}}
          end, ErrorsJson),
      receive
      {docs_remaining, 0} ->
          {ok, lists:flatten([ErrorsList|ErrorsAcc])};
      {docs_remaining, N} ->
          MoreDocs = lists:nthtail(length(Docs)-N, Docs),
          write_docs(Db, MoreDocs, [ErrorsList|ErrorsAcc])
      end;
  write_docs(Db, Docs, _) ->
  