updates
This commit is contained in:
@@ -367,11 +367,19 @@ function Save-OfficeDownload {
|
||||
$null = Write-Output "Download attempt ${attempt}: $Uri -> $Path"
|
||||
Invoke-WebRequest -UseBasicParsing -Uri $Uri -OutFile $Path -TimeoutSec $TimeoutSeconds -ErrorAction Stop
|
||||
if ((Get-Item -LiteralPath $Path -ErrorAction Stop).Length -eq 0) { throw 'Download was empty.' }
|
||||
if ($attempt -gt 1) { $null = Write-Output "Download recovered on attempt ${attempt}: $Uri -> $Path" }
|
||||
return
|
||||
} catch {
|
||||
Write-Error "Download attempt $attempt failed: $($_.Exception.Message)" -ErrorAction Continue
|
||||
if ($attempt -eq $definitions.DownloadAttempts) { throw }
|
||||
Start-Sleep -Seconds ($definitions.DownloadRetrySeconds * $attempt)
|
||||
$reason = $_.Exception.Message
|
||||
if ($attempt -eq $definitions.DownloadAttempts) {
|
||||
# The entry point logs and reports the terminal error once to Syncro.
|
||||
throw "Download failed after $attempt attempts: $Uri -> $Path. $reason"
|
||||
}
|
||||
$delay = $definitions.DownloadRetrySeconds * $attempt
|
||||
# Tools.ps1 logs Write-Output; suppress its echo so a recoverable attempt
|
||||
# neither pollutes return values nor produces an error in Syncro.
|
||||
$null = Write-Output "Download attempt $attempt of $($definitions.DownloadAttempts) failed for $Uri -> $Path. $reason Retrying in $delay seconds."
|
||||
Start-Sleep -Seconds $delay
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user