Skip to content

Commit 90ad5ac

Browse files
ralbertazziradoering
authored andcommitted
fix: revert #7916 to fix caching issue resulting in missing dependencies (#7995)
(cherry picked from commit f3f71ea)
1 parent e6fa00d commit 90ad5ac

File tree

3 files changed

+4
-32
lines changed

3 files changed

+4
-32
lines changed

src/poetry/repositories/http_repository.py

+4-8
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,11 @@ def _download(self, url: str, dest: Path) -> None:
7676

7777
@contextmanager
7878
def _cached_or_downloaded_file(self, link: Link) -> Iterator[Path]:
79-
filepath = self._authenticator.get_cached_file_for_url(link.url)
80-
if filepath:
79+
self._log(f"Downloading: {link.url}", level="debug")
80+
with temporary_directory() as temp_dir:
81+
filepath = Path(temp_dir) / link.filename
82+
self._download(link.url, filepath)
8183
yield filepath
82-
else:
83-
self._log(f"Downloading: {link.url}", level="debug")
84-
with temporary_directory() as temp_dir:
85-
filepath = Path(temp_dir) / link.filename
86-
self._download(link.url, filepath)
87-
yield filepath
8884

8985
def _get_info_from_wheel(self, url: str) -> PackageInfo:
9086
from poetry.inspection.info import PackageInfo

src/poetry/utils/authenticator.py

-8
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
from cachecontrol import CacheControlAdapter
2121
from cachecontrol.caches import FileCache
22-
from cachecontrol.caches.file_cache import url_to_file_path
2322
from filelock import FileLock
2423

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

467-
def get_cached_file_for_url(self, url: str) -> Path | None:
468-
if self._cache_control is None:
469-
return None
470-
471-
path = Path(url_to_file_path(url, self._cache_control))
472-
return path if path.exists() else None
473-
474466

475467
_authenticator: Authenticator | None = None
476468

tests/utils/test_authenticator.py

-16
Original file line numberDiff line numberDiff line change
@@ -627,22 +627,6 @@ def test_authenticator_git_repositories(
627627
assert not three.password
628628

629629

630-
def test_authenticator_get_cached_file_for_url__cache_miss(config: Config) -> None:
631-
authenticator = Authenticator(config, NullIO())
632-
assert (
633-
authenticator.get_cached_file_for_url("https://foo.bar/cache/miss.whl") is None
634-
)
635-
636-
637-
def test_authenticator_get_cached_file_for_url__cache_hit(config: Config) -> None:
638-
authenticator = Authenticator(config, NullIO())
639-
url = "https://foo.bar/files/foo-0.1.0.tar.gz"
640-
641-
authenticator._cache_control.set(url, b"hello")
642-
643-
assert authenticator.get_cached_file_for_url(url)
644-
645-
646630
@pytest.mark.parametrize(
647631
("ca_cert", "client_cert", "result"),
648632
[

0 commit comments

Comments
 (0)