anchor.diff:  %%%===================================================================
   %%% Internal functions
   %%%===================================================================
  +
  +
  +%% @private
  +-spec assert_file_does_not_exist(
  +    oct_background:entity_selector(),
  +    oct_background:entity_selector(),
  +    file_id:file_guid()
  +) ->
  +    ok.
  +assert_file_does_not_exist(ProviderSelector, UserSelector, FileGuid) ->
  +    Node = oct_background:get_random_provider_node(ProviderSelector),
  +    UserSessId = oct_background:get_user_session_id(UserSelector, ProviderSelector),
  +    ?assertMatch({error, ?ENOENT}, lfm_proxy:stat(Node, UserSessId, ?FILE_REF(FileGuid)), ?ATTEMPTS).
   
   
   %% @private
  
positive.code:     force_stale_uploads_removal(krakow),
      ?assertMatch(true, authorize_chunk_upload(krakow, user1, FileGuid)),
  
      time_test_utils:simulate_seconds_passing(2),
      force_stale_uploads_removal(krakow),
      ?assertMatch(false, authorize_chunk_upload(krakow, user1, FileGuid)),
  
      Node = oct_background:get_random_provider_node(krakow),
      UserSessId = oct_background:get_user_session_id(user1, krakow),
      ?assertMatch({error, ?ENOENT}, lfm_proxy:stat(Node, UserSessId, ?FILE_REF(FileGuid)), ?ATTEMPTS).
  
  
  upload_with_time_warps_test(_Config) ->
      [#object{guid = FileGuid}] = onenv_file_test_utils:create_and_sync_file_tree(
          user1, space_krk, #file_spec{}
      ),
  
negative.code:     % upload should not be canceled if time warps backward (whether write occurred or not)
      time_test_utils:simulate_seconds_passing(-1000),
      force_stale_uploads_removal(krakow),
      ?assertMatch(true, authorize_chunk_upload(krakow, user1, FileGuid)),
  
      % but will de removed if time equal to inactivity period (currently 1 minute)
      % passes from this new point in time (if no new activity occurred)
      time_test_utils:simulate_seconds_passing(61),
      force_stale_uploads_removal(krakow),
      ?assertMatch(false, authorize_chunk_upload(krakow, user1, FileGuid)),
      assert_file_does_not_exist(krakow, user1, FileGuid).
  
  
  upload_with_forward_time_warps_test(_Config) ->
      [#object{guid = FileGuid}] = onenv_file_test_utils:create_and_sync_file_tree(
          user1, space_krk, #file_spec{}
      ),
      ?assertMatch({ok, _}, initialize_gui_upload(krakow, user1, FileGuid)),
      ?assertMatch(true, authorize_chunk_upload(krakow, user1, FileGuid)),
  
      % upload should not be canceled in case of forward time warp if next chunk
      % was written before stale uploads checkup
      time_test_utils:simulate_seconds_passing(3000),
      do_multipart(krakow, user1, FileGuid, 5, 10, 1),
      force_stale_uploads_removal(krakow),
      ?assertMatch(true, authorize_chunk_upload(krakow, user1, FileGuid)),
  
      % otherwise it will be removed after inactivity period (currently 1 minute)
      time_test_utils:simulate_seconds_passing(61),
      force_stale_uploads_removal(krakow),
      ?assertMatch(false, authorize_chunk_upload(krakow, user1, FileGuid)),
      assert_file_does_not_exist(krakow, user1, FileGuid).
  
  
  %%%===================================================================
  