implement new Download-FileDirectly function to handle downloads

This commit is contained in:
2026-09-30 11:42:05 -04:00
parent 4e06ede640
commit 0975f5d24a
5 changed files with 79 additions and 31 deletions
+2 -2
View File
@@ -53,9 +53,9 @@ $DsaExecutablePath = Join-Path -Path $Global:ToolsDirectory -ChildPath 'dsa-coll
New-Item -Path $Global:ToolsDirectory -ItemType Directory -Force -ErrorAction Stop | Out-Null
Write-Output "Downloading dsa-collect.exe to ${DsaExecutablePath}"
$DsaDownloadedFile = Download-File -URL $DsaDownloadUrl -File $DsaExecutablePath -ErrorAction Stop
$DsaDownloadedFile = Download-FileDirectly -URL $DsaDownloadUrl -File $DsaExecutablePath -ErrorAction Stop
# Download-File can return nothing on failure. Do not run a stale executable.
# Require a returned path and a nonempty download before starting the collector.
If ( [string]::IsNullOrWhiteSpace([string]$DsaDownloadedFile) -or
!(Test-Path -LiteralPath $DsaExecutablePath -PathType Leaf) ) {
Throw "Failed to download dsa-collect.exe to ${DsaExecutablePath}"