def METHOD_NAME(self, link, package_name):
    can_not_cache = (
        not self.cache_dir or
        not package_name or
        not link
    )
    if can_not_cache:
        return []
    canonical_name = canonicalize_name(package_name)
    formats = index.fmt_ctl_formats(
        self.format_control, canonical_name
    )
    if not self.allowed_formats.intersection(formats):
        return []
    root = self.get_path_for_link(link)
    try:
        return os.listdir(root)
    except OSError as err:
        if err.errno in {errno.ENOENT, errno.ENOTDIR}:
            return []
        raise