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: -spec create({uuid, uuid()}, doc()) ->
      {ok, uuid()} | datastore:create_error().
  create({uuid, ParentUuid}, FileDoc) ->
      create({uuid, ParentUuid}, FileDoc, false, <<>>).
  
  %%--------------------------------------------------------------------
  %% @doc
  
negative.code:     {ok, uuid()} | datastore:create_error().
  create({uuid, ParentUuid}, FileDoc = #document{
      value = FileMeta = #file_meta{
          name = FileName,
          is_scope = IsScope
      }
  }, AllowConflicts) ->
      ?run(begin
          true = is_valid_filename(FileName),
          {ok, ParentDoc} = get(ParentUuid),
  
          FileDoc2 = fill_uuid(FileDoc),
          FileDoc3 = case IsScope of
              true ->
                  SpaceDirUuid = FileDoc2#document.key,
                  SpaceId = fslogic_uuid:space_dir_uuid_to_spaceid_no_error(SpaceDirUuid),
                  FileDoc2#document{
                      scope = SpaceId,
                      value = FileMeta#file_meta{
                          scope = SpaceDirUuid,
                          provider_id = oneprovider:get_provider_id(),
                          parent_uuid = ParentUuid
                      }};
              false ->
                  {ok, ScopeId} = get_scope_id(ParentDoc),
                  SpaceDirUuid = ScopeId,
                  SpaceId = fslogic_uuid:space_dir_uuid_to_spaceid_no_error(SpaceDirUuid),
                  FileDoc2#document{
                      scope = SpaceId,
                      value = FileMeta#file_meta{
                          scope = SpaceDirUuid,
                          provider_id = oneprovider:get_provider_id(),
                          parent_uuid = ParentUuid
                      }
                  }
          end,
          critical_section:run([?MODEL_NAME, ParentUuid],
              fun() ->
                  Exists = case AllowConflicts of
  