fix(Update-KHDB): dispose HttpResponseMessage on download

Invoke-DownloadWithRetry disposed the response stream and file handle
but never the HttpResponseMessage itself returned by GetAsync,
leaking one per shard download (the S3 code path already disposes
its response object). Added a finally block per attempt to dispose
it on both the success and retry/failure paths.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-07-29 12:05:30 +02:00
parent 2f0ff9085a
commit eea0ddf932
+3
View File
@@ -76,6 +76,7 @@ function Invoke-DownloadWithRetry {
$retries = 5
$delay = 2
for ($attempt = 0; $attempt -lt $retries; $attempt++) {
$response = $null
try {
$response = $Client.GetAsync($Uri, [System.Net.Http.HttpCompletionOption]::ResponseHeadersRead).Result
if (-not $response.IsSuccessStatusCode) {
@@ -115,6 +116,8 @@ function Invoke-DownloadWithRetry {
} else {
throw
}
} finally {
if ($response) { $response.Dispose() }
}
}
}