Commit d6e2d246 authored by Jan Reimes's avatar Jan Reimes
Browse files

refactor(core): rename shadowing param in download_to_file

Rename destination→target_file in http_client/session.py to avoid

shadowing the pathlib.Path class name and improve clarity.
parent fc06dce3
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -141,7 +141,7 @@ def resolve_ssl_verify(

def download_to_file(
    url: str,
    destination: Path,
    target_file: Path,
    session: requests.Session | None = None,
    close_session: bool = True,
    http_cache_file: Path | None = None,
@@ -154,7 +154,7 @@ def download_to_file(

    Args:
        url: Source URL
        destination: Destination path
        target_file: Destination file path
        session: Optional requests.Session to reuse. If None, a temporary cached session is created.
        close_session: Whether to close the session after download. Only applicable if a temporary session is created.
        http_cache_file: Optional explicit path to the HTTP cache database. Falls back to PathConfig default.
@@ -167,7 +167,7 @@ def download_to_file(
        ValueError: If URL scheme is not supported
        FileNotFoundError: If download fails
    """
    destination.parent.mkdir(parents=True, exist_ok=True)
    target_file.parent.mkdir(parents=True, exist_ok=True)
    lowered = url.lower()
    allowed_schemes = ("ftp://", "http://", "https://")
    if not lowered.startswith(allowed_schemes):
@@ -191,7 +191,7 @@ def download_to_file(
        timeout = pool_config.connection_timeout if pool_config is not None else 60
        response = active_session.get(url, timeout=timeout, stream=True)
        response.raise_for_status()
        with destination.open("wb") as target:
        with target_file.open("wb") as target:
            for chunk in response.iter_content(chunk_size=8192):
                if chunk:
                    target.write(chunk)
+4 −4
Original line number Diff line number Diff line
@@ -179,9 +179,9 @@ class SpecDownloads:
        url = SPEC_URL_TEMPLATE.format(series=series, normalized=normalized, file_name=target.file_name)
        return url, target.file_name

    def _download_full_zip(self, url: str, target_path: Path) -> None:
    def _download_full_zip(self, url: str, target_file: Path) -> None:
        """Download full zip file, re-use session if already created for doc-only attempt."""
        self.session = download_to_file(url, target_path, session=self.session, close_session=False, http_cache_file=self._http_cache_file)
        self.session = download_to_file(url, target_file, session=self.session, close_session=False, http_cache_file=self._http_cache_file)

    @staticmethod
    def _filter_versions_by_release(
@@ -247,8 +247,8 @@ class SpecDownloads:
                # Extract matching entries to target_dir
                for entry in entries:
                    if entry.path == doc_file:
                        target_path = target_dir / doc_file.split("/")[-1]
                        with target_path.open("wb") as f:
                        target_file = target_dir / doc_file.split("/")[-1]
                        with target_file.open("wb") as f:
                            async for _ in reader.extract(entry, f):
                                pass
                        return True