Skip to content

Commit

Permalink
Speed up initial UI display by performing query locale check in stage 1
Browse files Browse the repository at this point in the history
* UI display should now only be constrained by the time it takes to launch PowerShell
  • Loading branch information
pbatard committed Mar 18, 2019
1 parent bc488df commit 9c19e1c
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions Fido.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Fido v1.08 - Retail Windows ISO Downloader
# Fido v1.09 - Retail Windows ISO Downloader
# Copyright © 2019 Pete Batard <[email protected]>
# ConvertTo-ImageSource: Copyright © 2016 Chris Carter
#
Expand Down Expand Up @@ -438,14 +438,7 @@ if ($LocData -and (-not $LocData.StartsWith("en-US"))) {
}
$Locale = $Localized[0]
}
# Test if the Microsoft servers can handle our locale. If not, fall back to en-US.
$QueryLocale = $Locale
try {
$url = "https://www.microsoft.com/" + $QueryLocale + "/software-download/"
Invoke-WebRequest -UseBasicParsing -MaximumRedirection 0 -UserAgent $UserAgent $url | Out-Null
} catch {
$QueryLocale = "en-US"
}

# Make sure PowerShell 3.0 or later is used (for Invoke-WebRequest)
if ($PSVersionTable.PSVersion.Major -lt 3) {
Expand Down Expand Up @@ -513,6 +506,16 @@ $Continue.add_click({
switch ($Stage) {

1 { # Windows Version selection
$XMLForm.Title = Get-Translation($English[12])
Refresh-Control($XMLForm)
# Check if the locale we want is available - Fall back to en-US otherwise
try {
$url = "https://www.microsoft.com/" + $QueryLocale + "/software-download/"
Invoke-WebRequest -UseBasicParsing -MaximumRedirection 0 -UserAgent $UserAgent $url | Out-Null
} catch {
$script:QueryLocale = "en-US"
}

$i = 0
$array = @()
foreach ($Version in $WindowsVersions[$WindowsVersion.SelectedValue.Index]) {
Expand All @@ -524,6 +527,7 @@ $Continue.add_click({

$script:WindowsRelease = Add-Entry $Stage "Release" $array
$Back.Content = Get-Translation($English[8])
$XMLForm.Title = $AppTitle
}

2 { # Windows Release selection => Populate Product Edition
Expand Down

0 comments on commit 9c19e1c

Please sign in to comment.