Skip to content

Commit

Permalink
Don't redownload package if already done
Browse files Browse the repository at this point in the history
Match file found against size from catalog, warn if it doesn't match.
  • Loading branch information
theaquamarine committed Jun 16, 2019
1 parent 3b240d6 commit 6d7020e
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions Get-Bootcamp.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ $package = $esd.array.dict.selectnodes('key') | ForEach-Object {@{$($_.'#text')
$package += @{'ESDVersion' = $Version}
Write-Host "Selected $($package.ESDVersion) as it's the most recently posted."

# Download the BootCamp ESD
$landingDir = Join-Path $OutputDir "BootCamp-$($package.ESDVersion)"
$workingDir = Join-Path $env:Temp "BootCamp-unpack-$($package.ESDVersion)"
$packagePath = Join-Path $workingDir 'BootCampESD.pkg'
Expand All @@ -69,9 +68,20 @@ if (Test-Path -PathType Container $landingDir) {
}
if (-not (Test-Path -PathType Container $workingDir)) {mkdir $workingDir > $null}

Write-Host "Starting download from $($package.URL)"
Start-BitsTransfer -Source $package.URL -Destination "$packagePath" -ErrorAction Stop
Write-Host "Download complete"
# Download the BootCamp ESD if required
if (-not (Test-Path -PathType Leaf $packagePath)) {
Write-Host "Starting download from $($package.URL)"
Start-BitsTransfer -Source $package.URL -Destination "$packagePath" -ErrorAction Stop
Write-Host "Download complete"
} else {
# Not sure what's used for the digest, but we can match size.
if ((Get-Item $packagePath | Select -ExpandProperty Length) -eq $package.Size) {
Write-Host "$($package.ESDVersion) already exists at $packagePath, not redownloading."
} else {
Write-Warning "A file already exists at $packagePath but does not match $($package.URL), please remove it."
exit 1
}
}
if (Test-Path -Path "$packagePath") {
# Extract the bootcamp installer
Write-Host "Extracting..."
Expand Down

0 comments on commit 6d7020e

Please sign in to comment.