@read_session
def __exists_replicas(rse_id, scope=None, name=None, path=None, session=None):
    '\n    Internal method to check if a replica exists at a given site.\n    :param rse_id: The RSE id.\n    :param scope: The scope of the file.\n    :param name: The name of the file.\n    :param path: The path of the replica.\n    :param session: The database session in use.\n    '
    already_declared = False
    if path:
        path_clause = [(models.RSEFileAssociation.path == path)]
        if path.startswith('/'):
            path_clause.append((models.RSEFileAssociation.path == path[1:]))
        else:
            path_clause.append((models.RSEFileAssociation.path == ('/%s' % path)))
        query = session.query(models.RSEFileAssociation.path, models.RSEFileAssociation.scope, models.RSEFileAssociation.name, models.RSEFileAssociation.rse_id, models.RSEFileAssociation.bytes).with_hint(models.RSEFileAssociation, '+ index(replicas REPLICAS_PATH_IDX', 'oracle').filter((models.RSEFileAssociation.rse_id == rse_id)).filter(or_(*path_clause))
    else:
        query = session.query(models.RSEFileAssociation.path, models.RSEFileAssociation.scope, models.RSEFileAssociation.name, models.RSEFileAssociation.rse_id, models.RSEFileAssociation.bytes).filter_by(rse_id=rse_id, scope=scope, name=name)
    if query.count():
        result = query.first()
        (path, scope, name, rse_id, size) = result
        query = session.query(models.BadReplicas.scope, models.BadReplicas.name, models.BadReplicas.rse_id, models.BadReplicas.state).filter_by(rse_id=rse_id, scope=scope, name=name, state=BadFilesStatus.BAD)
        if query.count():
            already_declared = True
        return (True, scope, name, already_declared, size)
    else:
        return (False, None, None, already_declared, None)
Internal method to check if a replica exists at a given site.
:param rse_id: The RSE id.
:param scope: The scope of the file.
:param name: The name of the file.
:param path: The path of the replica.
:param session: The database session in use.
@read_session
def __exists_replicas(rse_id, scope=None, name=None, path=None, session=None):
    '\n    Internal method to check if a replica exists at a given site.\n    :param rse_id: The RSE id.\n    :param scope: The scope of the file.\n    :param name: The name of the file.\n    :param path: The path of the replica.\n    :param session: The database session in use.\n    '
    already_declared = False
    if path:
        path_clause = [(models.RSEFileAssociation.path == path)]
        if path.startswith('/'):
            path_clause.append((models.RSEFileAssociation.path == path[1:]))
        else:
            path_clause.append((models.RSEFileAssociation.path == ('/%s' % path)))
        query = session.query(models.RSEFileAssociation.path, models.RSEFileAssociation.scope, models.RSEFileAssociation.name, models.RSEFileAssociation.rse_id, models.RSEFileAssociation.bytes).with_hint(models.RSEFileAssociation, '+ index(replicas REPLICAS_PATH_IDX', 'oracle').filter((models.RSEFileAssociation.rse_id == rse_id)).filter(or_(*path_clause))
    else:
        query = session.query(models.RSEFileAssociation.path, models.RSEFileAssociation.scope, models.RSEFileAssociation.name, models.RSEFileAssociation.rse_id, models.RSEFileAssociation.bytes).filter_by(rse_id=rse_id, scope=scope, name=name)
    if query.count():
        result = query.first()
        (path, scope, name, rse_id, size) = result
        query = session.query(models.BadReplicas.scope, models.BadReplicas.name, models.BadReplicas.rse_id, models.BadReplicas.state).filter_by(rse_id=rse_id, scope=scope, name=name, state=BadFilesStatus.BAD)
        if query.count():
            already_declared = True
        return (True, scope, name, already_declared, size)
    else:
        return (False, None, None, already_declared, None)