Execute web requests only once
This commit is contained in:
parent
60d9691f45
commit
de58359af4
1 changed files with 3 additions and 2 deletions
|
@ -6,12 +6,13 @@ function Install-SoftwarePackage([Context] $context, [string] $location, [string
|
|||
|
||||
if (-not ($local.IsPresent)) {
|
||||
$tempDir = $context.GetTempDirectory();
|
||||
$tempFile = Join-Path $tempDir "download.tmp";
|
||||
|
||||
$response = Invoke-WebRequest $location;
|
||||
$response = Invoke-WebRequest $location -OutFile $tempFile;
|
||||
$fileName = [System.IO.Path]::GetFileName($response.Headers["Location"]);
|
||||
|
||||
$filePath = Join-Path $tempDir $fileName;
|
||||
Invoke-WebRequest $location $filePath;
|
||||
Move-Item $tempFile $filePath;
|
||||
} else {
|
||||
$filePath = $location;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue