anchor.diff:      SizeAcc2 ->
           {#batch{docs = [Doc | DocAcc], size = SizeAcc2}, 0, 0}
       end.
  +
  +
  +batch_doc(#doc{atts = []}) ->
  +    true;
  +batch_doc(#doc{atts = Atts}) ->
  +    (length(Atts) =< ?MAX_BULK_ATTS_PER_DOC) andalso
  +        lists:all(
  +            fun(#att{disk_len = L, data = Data}) ->
  +                (L =< ?MAX_BULK_ATT_SIZE) andalso (Data =/= stub)
  +            end, Atts).
   
   
   flush_docs(_Target, []) ->
  
positive.code:     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
      true ->
          {Target, DocList, W + 1, F};
      false ->
          {Target, DocList, W, F + 1}
      end;
  local_doc_handler(_, Acc) ->
      Acc.
  
negative.code:         _ ->
              {Batch, 0, 1}
          end;
      true ->
          JsonDoc = ?JSON_ENCODE(couch_doc:to_json_obj(Doc, [revs, attachments])),
          case SizeAcc + iolist_size(JsonDoc) of
          SizeAcc2 when SizeAcc2 > ?DOC_BUFFER_BYTE_SIZE ->
  