anchor.diff:      end.
   
   
  -local_doc_handler({ok, #doc{atts = []} = Doc}, {Target, DocList, W, F}) ->
  -    {Target, [Doc | DocList], W, F};
   local_doc_handler({ok, Doc}, {Target, DocList, W, F}) ->
  -    ?LOG_DEBUG("Worker flushing doc with attachments", []),
  -    Target2 = open_db(Target),
  -    Success = (flush_doc(Target2, Doc) =:= ok),
  -    close_db(Target2),
  -    case Success of
  +    case batch_doc(Doc) of
       true ->
  -        {Target, DocList, W + 1, F};
  +        {Target, [Doc | DocList], W, F};
       false ->
  -        {Target, DocList, W, F + 1}
  +        ?LOG_DEBUG("Worker flushing doc with attachments", []),
  +        Target2 = open_db(Target),
  +        Success = (flush_doc(Target2, Doc) =:= ok),
  +        close_db(Target2),
  +        case Success of
  +        true ->
  +            {Target, DocList, W + 1, F};
  +        false ->
  +            {Target, DocList, W, F + 1}
  +        end
       end;
   local_doc_handler(_, Acc) ->
       Acc.
  
positive.code:         _ ->
              {Batch, 0, 1}
          end;
      false ->
          JsonDoc = ?JSON_ENCODE(couch_doc:to_json_obj(Doc, [revs, attachments])),
          case SizeAcc + iolist_size(JsonDoc) of
          SizeAcc2 when SizeAcc2 > ?DOC_BUFFER_BYTE_SIZE ->
  
negative.code: 
  
  maybe_flush_docs(#httpdb{} = Target,
      #batch{docs = DocAcc, size = SizeAcc} = Batch, Doc) ->
      case batch_doc(Doc) of
      false ->
          ?LOG_DEBUG("Worker flushing doc with attachments", []),
          case flush_doc(Target, Doc) of
          ok ->
  