List/ Mods Path critical corrections
parent
11ee64ec57
commit
72bcf77672
|
@ -80,6 +80,10 @@ if (Test-Network) {
|
|||
if ($WAUConfig.WAU_ListPath) {
|
||||
Write-Log "WAU uses External Lists from: $($WAUConfig.WAU_ListPath.TrimEnd(" ", "\", "/"))"
|
||||
$NewList = Test-ListPath $WAUConfig.WAU_ListPath.TrimEnd(" ", "\", "/") $WAUConfig.WAU_UseWhiteList $WAUConfig.InstallLocation.TrimEnd(" ", "\")
|
||||
if ($ReachNoPath) {
|
||||
Write-Log "Couldn't reach/find/compare/copy from $($WAUConfig.WAU_ListPath.TrimEnd(" ", "\", "/"))..." "Red"
|
||||
$Script:ReachNoPath = $False
|
||||
}
|
||||
if ($NewList) {
|
||||
Write-Log "Newer List downloaded/copied to local path: $($WAUConfig.InstallLocation.TrimEnd(" ", "\"))" "Yellow"
|
||||
}
|
||||
|
@ -102,6 +106,10 @@ if (Test-Network) {
|
|||
if ($WAUConfig.WAU_ModsPath) {
|
||||
Write-Log "WAU uses External Mods from: $($WAUConfig.WAU_ModsPath.TrimEnd(" ", "\", "/"))"
|
||||
$NewMods, $DeletedMods = Test-ModsPath $WAUConfig.WAU_ModsPath.TrimEnd(" ", "\", "/") $WAUConfig.InstallLocation.TrimEnd(" ", "\")
|
||||
if ($ReachNoPath) {
|
||||
Write-Log "Couldn't reach/find/compare/copy from $($WAUConfig.WAU_ModsPath.TrimEnd(" ", "\", "/"))..." "Red"
|
||||
$Script:ReachNoPath = $False
|
||||
}
|
||||
if ($NewMods -gt 0) {
|
||||
Write-Log "$NewMods newer Mods downloaded/copied to local path: $($WAUConfig.InstallLocation.TrimEnd(" ", "\"))\mods" "Yellow"
|
||||
}
|
||||
|
|
|
@ -30,29 +30,41 @@ function Test-ListPath ($ListPath, $UseWhiteList, $WingetUpdatePath) {
|
|||
$wc.DownloadFile($ExternalList, $LocalList)
|
||||
}
|
||||
catch {
|
||||
$Script:ReachNoPath = $True
|
||||
return $False
|
||||
}
|
||||
return $true
|
||||
}
|
||||
}
|
||||
catch {
|
||||
$Script:ReachNoPath = $True
|
||||
return $False
|
||||
}
|
||||
}
|
||||
# If path is UNC or local
|
||||
else {
|
||||
if (Test-Path -Path $ExternalList -PathType leaf) {
|
||||
$dateExternal = (Get-Item "$ExternalList").LastWriteTime.ToString("yyyy-MM-dd HH:mm:ss")
|
||||
if (Test-Path -Path $ExternalList) {
|
||||
try {
|
||||
$dateExternal = (Get-Item "$ExternalList").LastWriteTime.ToString("yyyy-MM-dd HH:mm:ss")
|
||||
}
|
||||
catch {
|
||||
$Script:ReachNoPath = $True
|
||||
return $False
|
||||
}
|
||||
if ($dateExternal -gt $dateLocal) {
|
||||
try {
|
||||
Copy-Item $ExternalList -Destination $LocalList -Force
|
||||
}
|
||||
catch {
|
||||
$Script:ReachNoPath = $True
|
||||
return $False
|
||||
}
|
||||
return $true
|
||||
return $True
|
||||
}
|
||||
}
|
||||
else {
|
||||
$Script:ReachNoPath = $True
|
||||
}
|
||||
return $False
|
||||
}
|
||||
return $false
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ function Test-ModsPath ($ModsPath, $WingetUpdatePath) {
|
|||
$WebResponse = Invoke-WebRequest -Uri $ExternalMods -UseBasicParsing
|
||||
}
|
||||
catch {
|
||||
$Script:ReachNoPath = $True
|
||||
return $False
|
||||
}
|
||||
|
||||
|
@ -73,12 +74,12 @@ function Test-ModsPath ($ModsPath, $WingetUpdatePath) {
|
|||
$ModsUpdated++
|
||||
}
|
||||
catch {
|
||||
# Error handling
|
||||
$Script:ReachNoPath = $True
|
||||
}
|
||||
}
|
||||
}
|
||||
catch {
|
||||
# Error handling
|
||||
$Script:ReachNoPath = $True
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -89,13 +90,17 @@ function Test-ModsPath ($ModsPath, $WingetUpdatePath) {
|
|||
if ((Test-Path -Path $ExternalMods"\*.ps1") -or (Test-Path -Path $ExternalMods"\*.txt")) {
|
||||
#Get File Names Externally
|
||||
$ExternalModsNames = Get-ChildItem -Path $ExternalMods -Name -Recurse -Include *.ps1, *.txt
|
||||
|
||||
#Delete Local Mods that don't exist Externally
|
||||
$DeletedMods = 0
|
||||
foreach ($Mod in $InternalModsNames){
|
||||
If($Mod -notin $ExternalModsNames ){
|
||||
If ($Mod -notin $ExternalModsNames ){
|
||||
Remove-Item $LocalMods\$Mod -Force -ErrorAction SilentlyContinue | Out-Null
|
||||
$DeletedMods++
|
||||
}
|
||||
}
|
||||
|
||||
#Copy newer external mods
|
||||
try {
|
||||
foreach ($Mod in $ExternalModsNames){
|
||||
$dateExternalMod = ""
|
||||
|
@ -112,9 +117,12 @@ function Test-ModsPath ($ModsPath, $WingetUpdatePath) {
|
|||
|
||||
}
|
||||
catch {
|
||||
# Error handling
|
||||
$Script:ReachNoPath = $True
|
||||
}
|
||||
}
|
||||
else {
|
||||
$Script:ReachNoPath = $True
|
||||
}
|
||||
return $ModsUpdated, $DeletedMods
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue