from pathlib import Path


def __db_file_exist(path: str, failsafe: bool = False) -> str:
    """
    Check that the specified file exists in the database directory. Returns respective boolean.

    :param path: path to the database file
    :param failsafe: specifies if the exception should be raised in case
        the file is not found, defaults to :py:obj:`False`
    :raises FileNotFoundError: if the specified file is not found
    :return: path of the database file
    """
    if not Path(path).exists() and not failsafe:
        raise FileNotFoundError(f"Database file not found in path {path}")
    return path