Skip to content

Commit c6d0b0c

Browse files
McSinyxpradyunsg
andauthored
Comment and rework conditionals in download dir check
Co-authored-by: Pradyun Gedam <[email protected]>
1 parent c947d00 commit c6d0b0c

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/pip/_internal/operations/prepare.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -486,20 +486,24 @@ def prepare_linked_requirement(self, req, parallel_builds=False):
486486
link = req.link
487487
self._log_preparing_link(req)
488488
with indent_log():
489+
# Check if the relevant file is already available in the download directory
490+
file_path = None
489491
download_dir = self._get_download_dir(req.link)
490492
if download_dir is not None and link.is_wheel:
491493
hashes = self._get_linked_req_hashes(req)
492494
file_path = _check_download_dir(req.link, download_dir, hashes)
493-
if file_path is not None:
494-
self._downloaded[req.link.url] = file_path, None
495-
else:
496-
file_path = None
497495

498-
if file_path is None:
496+
if file_path is not None:
497+
# The file is already available, so mark it as downloaded
498+
self._downloaded[req.link.url] = file_path, None
499+
else:
500+
# The file is not available, attempt to fetch only metadata.
499501
wheel_dist = self._fetch_metadata_using_lazy_wheel(link)
500502
if wheel_dist is not None:
501503
req.needs_more_preparation = True
502504
return wheel_dist
505+
506+
# None of the optimizations worked, fully prepare the requirement.
503507
return self._prepare_linked_requirement(req, parallel_builds)
504508

505509
def prepare_linked_requirements_more(self, reqs, parallel_builds=False):

0 commit comments

Comments
 (0)