anchor.diff:  -spec create_or_update(datastore:document(), Diff :: datastore:document_diff()) ->
       {ok, datastore:ext_key()} | datastore:update_error().
   create_or_update(Doc, Diff) ->
  -    case datastore:create_or_update(?STORE_LEVEL, Doc, Diff) of
  -        {ok, Uuid} ->
  -            catch file_meta:setup_onedata_user(provider, Uuid),
  -            {ok, Uuid};
  -        Error ->
  -            Error
  -    end.
  +    run_and_update_user(fun datastore:create_or_update/3, [?STORE_LEVEL, Doc, Diff]).
   
   %%--------------------------------------------------------------------
   %% @doc
  
positive.code: %%--------------------------------------------------------------------
  -spec create(datastore:document()) -> {ok, datastore:key()} | datastore:create_error().
  create(Document) ->
      case datastore:create(?STORE_LEVEL, Document) of
          {ok, Uuid} ->
              catch file_meta:setup_onedata_user(provider, Uuid),
              {ok, Uuid};
          Error ->
              Error
      end.
  
  %%--------------------------------------------------------------------
  %% @doc
  
negative.code: %%%===================================================================
  %%% Internal functions
  %%%===================================================================
  
  %%--------------------------------------------------------------------
  %% @doc
  %% Run function and in case of success, update user's file_meta space structures.
  %% @end
  %%--------------------------------------------------------------------
  -spec run_and_update_user(function(), list()) -> {ok, datastore:ext_key()} | datastore:update_error().
  run_and_update_user(Function, Args) ->
      case apply(Function, Args) of
          {ok, Uuid} ->
              file_meta:setup_onedata_user(provider, Uuid),
              {ok, Uuid};
          Error ->
              Error
      end.