Error handling
parent
991dd55c2f
commit
3262d11099
|
@ -16,19 +16,26 @@ function Test-ModsPath ($ModsPath, $WingetUpdatePath) {
|
||||||
# enable TLS 1.2 and TLS 1.1 protocols
|
# enable TLS 1.2 and TLS 1.1 protocols
|
||||||
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12, [Net.SecurityProtocolType]::Tls11
|
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12, [Net.SecurityProtocolType]::Tls11
|
||||||
#Get Index of $ExternalMods (or index page with href listings of all the Mods)
|
#Get Index of $ExternalMods (or index page with href listings of all the Mods)
|
||||||
$WebResponse = Invoke-WebRequest -Uri $ExternalMods
|
try {
|
||||||
# Get the list of links, skip the first one ("../") if listing is allowed
|
$WebResponse = Invoke-WebRequest -Uri $ExternalMods
|
||||||
$ModLinks = $WebResponse.Links | Select-Object -ExpandProperty href -Skip 1
|
}
|
||||||
|
catch {
|
||||||
|
return $False
|
||||||
|
}
|
||||||
|
|
||||||
#Delete Local Mods that doesn't exist Externally
|
#Delete Local Mods that doesn't exist Externally
|
||||||
foreach ($Mod in $InternalModsNames) {
|
if ($WebResponse) {
|
||||||
try {
|
# Get the list of links, skip the first one ("../") if listing is allowed
|
||||||
If ($Mod -notin $ModLinks) {
|
$ModLinks = $WebResponse.Links | Select-Object -ExpandProperty href -Skip 1
|
||||||
Remove-Item $LocalMods\$Mod -Force | Out-Null
|
foreach ($Mod in $InternalModsNames) {
|
||||||
|
try {
|
||||||
|
If ($Mod -notin $ModLinks) {
|
||||||
|
Remove-Item $LocalMods\$Mod -Force | Out-Null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
#Do nothing
|
||||||
}
|
}
|
||||||
}
|
|
||||||
catch {
|
|
||||||
#Do nothing
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue