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