anchor.diff:          end
       end;
   
  -maybe_flush_docs(#db{} = Target, #batch{docs = DocAcc, size = SizeAcc},
  -    #doc{atts = []} = Doc) ->
  +maybe_flush_docs(#db{} = Target, #batch{docs = DocAcc, size = SizeAcc}, Doc) ->
       case SizeAcc + 1 of
       SizeAcc2 when SizeAcc2 >= ?DOC_BUFFER_LEN ->
           ?LOG_DEBUG("Worker flushing doc batch of ~p docs", [SizeAcc2]),
  
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:     end.
  
  
  local_doc_handler({ok, Doc}, {Target, DocList, W, F}) ->
      case batch_doc(Doc) of
      true ->
          {Target, [Doc | DocList], W, F};
      false ->
          ?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.
  