anchor.diff:      {ok, State :: #state{}} | {ok, State :: #state{}, timeout() | hibernate} |
       {stop, Reason :: term()} | ignore.
   init([SessionId, FileEntry, ProviderId, Callback]) ->
  +    Server = self(),
       spawn(fun() ->
           try
  -            ok = onedata_file_api:replicate_file(SessionId, FileEntry, ProviderId)
  +            gen_server:cast(Server, transfer_active),
  +            ok = onedata_file_api:replicate_file(SessionId, FileEntry, ProviderId),
  +            gen_server:cast(Server, transfer_completed)
           catch
               _:E ->
  +                gen_server:cast(Server, transfer_failed),
                   ?error_stacktrace("Could not replicate file ~p due to ~p", [FileEntry, E])
           end
       end),
  -    {ok, #state{}}.
  +    FilePath =
  +        case FileEntry of
  +            {path, Path} ->
  +                Path;
  +            {guid, Guid} ->
  +                {ok, Path} = onedata_file_api:get_file_path(SessionId, Guid),
  +                Path
  +        end,
  +    {ok, #state{session_id = SessionId, status = scheduled, callback = Callback,
  +        path = FilePath, target_provider_id = ProviderId}}.
   
   %%--------------------------------------------------------------------
   %% @private
  
positive.code: 
  -define(SERVER, ?MODULE).
  
  -record(state, {session_id :: session:id()}).
  
  %%%===================================================================
  %%% API
  
negative.code:     {noreply, NewState :: #state{}, timeout() | hibernate} |
      {stop, Reason :: term(), Reply :: term(), NewState :: #state{}} |
      {stop, Reason :: term(), NewState :: #state{}}.
  handle_call(get_info, _From, State = #state{status = Status, path = Path, target_provider_id = TargetProviderId}) ->
      Response = [
          {<<"path">>, Path},
          {<<"status">>, atom_to_binary(Status, utf8)},
          {<<"targetProviderId">>, TargetProviderId}
      ],
      {reply, Response, State};
  handle_call(get_status, _From, State) ->
      {reply, State#state.status, State};
  handle_call(_Request, _From, State) ->
      ?log_bad_request(_Request),
      {reply, wrong_request, State}.
  