Skip to content

Commit

Permalink
make sure DownloadedExternalFiles var always exists
Browse files Browse the repository at this point in the history
  • Loading branch information
jantari committed Aug 19, 2019
1 parent b6c7dfb commit 24f4461
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions LSUClient.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -441,15 +441,16 @@ function Get-LSUpdate {
Write-Verbose "A total of $($PARSEDXML.packages.count) driver packages are available for this computer model."

foreach ($packageURL in $PARSEDXML.packages.package) {
$packageXMLOrig = $webClient.DownloadString($packageURL.location)
[xml]$packageXML = $packageXMLOrig -replace "^$UTF8ByteOrderMark"
$rawPackageXML = $webClient.DownloadString($packageURL.location)
[xml]$packageXML = $rawPackageXML -replace "^$UTF8ByteOrderMark"
$DownloadedExternalFiles = [System.Collections.Generic.List[System.IO.FileInfo]]::new()

if ($packageXML.Package.Files.External) {
# Downloading files needed by external detection in package dependencies
[array]$DownloadedExternalFiles = foreach ($externalFile in $packageXML.Package.Files.External.ChildNodes) {
foreach ($externalFile in $packageXML.Package.Files.External.ChildNodes) {
[string]$DownloadDest = Join-Path -Path $env:Temp -ChildPath $externalFile.Name
$webClient.DownloadFile(($packageURL.location -replace "[^/]*$") + $externalFile.Name, $DownloadDest)
[System.IO.FileInfo]::new($DownloadDest)
$DownloadedExternalFiles.Add( [System.IO.FileInfo]::new($DownloadDest) )
}
}

Expand Down

0 comments on commit 24f4461

Please sign in to comment.