Download a single toolchain package. Args: package: Package information cache_dir: Cache directory for downloads downloader: ResumableDownloader instance Returns: ToolchainDownloadResult with download status
(
package: PackageInfo, cache_dir: Path, downloader: ResumableDownloader
)
| 100 | |
| 101 | |
| 102 | def download_toolchain( |
| 103 | package: PackageInfo, cache_dir: Path, downloader: ResumableDownloader |
| 104 | ) -> ToolchainDownloadResult: |
| 105 | """ |
| 106 | Download a single toolchain package. |
| 107 | |
| 108 | Args: |
| 109 | package: Package information |
| 110 | cache_dir: Cache directory for downloads |
| 111 | downloader: ResumableDownloader instance |
| 112 | |
| 113 | Returns: |
| 114 | ToolchainDownloadResult with download status |
| 115 | """ |
| 116 | result = ToolchainDownloadResult(package_name=package.name, url="") |
| 117 | |
| 118 | # Get download URL from package |
| 119 | try: |
| 120 | download_url = package.get_download_url() |
| 121 | except KeyboardInterrupt as ki: |
| 122 | handle_keyboard_interrupt(ki) |
| 123 | raise |
| 124 | except Exception as e: |
| 125 | result.error_message = f"Failed to resolve download URL: {e}" |
| 126 | return result |
| 127 | |
| 128 | if not download_url: |
| 129 | result.error_message = "No download URL available" |
| 130 | return result |
| 131 | |
| 132 | result.url = download_url |
| 133 | |
| 134 | # Try to convert GitHub URLs to zip format |
| 135 | converted_url, needs_manual = convert_github_url_to_zip(download_url) |
| 136 | |
| 137 | if needs_manual: |
| 138 | result.needs_manual_install = True |
| 139 | result.error_message = "Requires manual git installation" |
| 140 | return result |
| 141 | |
| 142 | # Use converted URL if available, otherwise use original |
| 143 | final_url = converted_url if converted_url else download_url |
| 144 | result.converted_url = final_url if converted_url else None |
| 145 | |
| 146 | # Acquire fine-grained lock for this specific artifact (5-second timeout with stale detection) |
| 147 | try: |
| 148 | with acquire_artifact_lock( |
| 149 | cache_dir, final_url, operation="download", timeout=5.0 |
| 150 | ): |
| 151 | # Check cache again (another process might have completed while we waited for lock) |
| 152 | cached_artifact = check_cached_download( |
| 153 | cache_dir, final_url, expected_filename="toolchain.zip" |
| 154 | ) |
| 155 | |
| 156 | if cached_artifact: |
| 157 | logger.info(f"✅ Using cached toolchain: {package.name}") |
| 158 | result.success = True |
| 159 | result.cache_dir = cached_artifact |
nothing calls this directly
no test coverage detected