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:
@@ -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() }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user