anchor.diff:  
   %%--------------------------------------------------------------------
   %% @doc
  +%% Gets "scope" id of given document. "Scope" document is the nearest ancestor with #file_meta.is_scope == true.
  +%% @end
  +%%--------------------------------------------------------------------
  +-spec get_scope_id(Entry :: entry()) -> {ok, ScopeId :: datastore:ext_key()} | datastore:generic_error().
  +get_scope_id(#document{key = FileUuid, value = #file_meta{is_scope = true}}) ->
  +    {ok, FileUuid};
  +get_scope_id(#document{value = #file_meta{is_scope = false, scope = Scope}}) ->
  +    {ok, Scope};
  +get_scope_id(Entry) ->
  +    ?run(begin
  +        {ok, Doc} = get(Entry),
  +        get_scope_id(Doc)
  +    end).
  +
  +%%--------------------------------------------------------------------
  +%% @doc
   %% Initializes files metadata for onedata user.
   %% This function can and should be used to ensure that user's FS is fully synchronised. Normally
   %% this function is called asynchronously automatically after user's document is updated.
  
positive.code:     {ok, uuid()} | datastore:create_error().
  create({uuid, ParentUuid}, FileDoc = #document{
      value = FileMeta = #file_meta{
          name = FileName
      }
  }, AllowConflicts, ScopeId) ->
      ?run(begin
          {ok, ParentDoc} = get(ParentUuid),
          {ok, Scope} = get_scope(ParentDoc),
          NewFileMeta = FileMeta#file_meta{scope = Scope#document.key,
              provider_id = oneprovider:get_provider_id(), parent_uuid = ParentUuid},
          FileDoc2 =
              case FileDoc of
                  #document{key = undefined} = Doc ->
                      NewUuid = gen_file_uuid(),
                      Doc#document{key = NewUuid, value = NewFileMeta};
                  _ ->
                      FileDoc#document{value = NewFileMeta}
              end,
          {ok, DocScope} = get_scope(FileDoc2),
          ScopeId = fslogic_uuid:space_dir_uuid_to_spaceid_no_error(DocScope#document.key),
          FileDoc3 = FileDoc2#document{value = NewFileMeta, scope = ScopeId},
          critical_section:run([?MODEL_NAME, ParentUuid],
              fun() ->
                  Exists = case AllowConflicts of
  
negative.code:             parent_uuid = ParentUuidInDoc
          }
      }} = get(Entry),
      {ok, ScopeId} = get_scope_id(Parent),
      ok = model:execute_with_default_context(?MODULE, set_links,
          [ParentDoc, {FileName, FileDoc}]),
      ok = set_scope(FileDoc, ScopeId),
      case ParentUuidInDoc =/= ParentUuid of
          true ->
              update(FileUuid, #{parent_uuid => ParentUuid});
  