anchor.diff:  }).
   
   -type state() :: #state{}.
  --type traverse_status() :: in_progress | finished.
  +-type download_status() :: in_progress | finished.
   
   
   -define(TARBALL_DOWNLOAD_TRAVERSE_POOL_NAME, bulk_download_traverse:get_pool_name()).
  
positive.code: 
  %% @private
  -spec wait_for_conn(state()) -> state().
  wait_for_conn(State) ->
      wait_for_conn(State, in_progress).
  
  
  %% @private
  -spec wait_for_conn(state(), traverse_status()) -> state().
  wait_for_conn(#state{id = Id} = State, TraverseStatus) ->
      receive
          ?MSG_ABORT ->
              finalize(State);
          ?MSG_DATA_SENT(NewDelay) -> 
              case TraverseStatus of
                  finished -> wait_for_conn(State#state{send_retry_delay = NewDelay}, TraverseStatus);
                  in_progress -> State#state{send_retry_delay = NewDelay}
              end;
          ?MSG_CHECK_OFFSET(NewConn, Offset) ->
              NewConn ! is_offset_within_buffer_bounds(State, Offset),
              wait_for_conn(State, TraverseStatus);
          ?MSG_RESUMED(NewConn, ResumeOffset) ->
              UpdatedState = handle_resume(State, NewConn, ResumeOffset, TraverseStatus),
              wait_for_conn(UpdatedState, TraverseStatus)
      after ?BULK_DOWNLOAD_RESUME_TIMEOUT ->
          file_download_code:remove(Id),
          bulk_download_task:delete(Id),
  
negative.code:         send_data(tar_utils:close_archive_stream(FinalTarStream), UpdatedState),
      tree_traverse_session:close_for_task(BulkDownloadId),
      Conn ! ?MSG_DONE,
      wait_for_conn_upon_finish(FinalState). % do not die yet, last chunk might have failed
  
  
  %% @private
  