Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: revert #7916 #7995

Merged
merged 1 commit into from
May 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions src/poetry/repositories/http_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,11 @@ def _download(self, url: str, dest: Path) -> None:

@contextmanager
def _cached_or_downloaded_file(self, link: Link) -> Iterator[Path]:
filepath = self._authenticator.get_cached_file_for_url(link.url)
if filepath:
self._log(f"Downloading: {link.url}", level="debug")
with temporary_directory() as temp_dir:
filepath = Path(temp_dir) / link.filename
self._download(link.url, filepath)
yield filepath
else:
self._log(f"Downloading: {link.url}", level="debug")
with temporary_directory() as temp_dir:
filepath = Path(temp_dir) / link.filename
self._download(link.url, filepath)
yield filepath

def _get_info_from_wheel(self, url: str) -> PackageInfo:
from poetry.inspection.info import PackageInfo
Expand Down
8 changes: 0 additions & 8 deletions src/poetry/utils/authenticator.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

from cachecontrol import CacheControlAdapter
from cachecontrol.caches import FileCache
from cachecontrol.caches.file_cache import url_to_file_path
from filelock import FileLock

from poetry.config.config import Config
Expand Down Expand Up @@ -464,13 +463,6 @@ def _get_certs_for_url(self, url: str) -> RepositoryCertificateConfig:
return selected.certs(config=self._config)
return RepositoryCertificateConfig()

def get_cached_file_for_url(self, url: str) -> Path | None:
if self._cache_control is None:
return None

path = Path(url_to_file_path(url, self._cache_control))
return path if path.exists() else None


_authenticator: Authenticator | None = None

Expand Down
16 changes: 0 additions & 16 deletions tests/utils/test_authenticator.py
Original file line number Diff line number Diff line change
Expand Up @@ -627,22 +627,6 @@ def test_authenticator_git_repositories(
assert not three.password


def test_authenticator_get_cached_file_for_url__cache_miss(config: Config) -> None:
authenticator = Authenticator(config, NullIO())
assert (
authenticator.get_cached_file_for_url("https://foo.bar/cache/miss.whl") is None
)


def test_authenticator_get_cached_file_for_url__cache_hit(config: Config) -> None:
authenticator = Authenticator(config, NullIO())
url = "https://foo.bar/files/foo-0.1.0.tar.gz"

authenticator._cache_control.set(url, b"hello")

assert authenticator.get_cached_file_for_url(url)


@pytest.mark.parametrize(
("ca_cert", "client_cert", "result"),
[
Expand Down