Log Deleted Local Mods

pull/232/head
KnifMelti 2022-11-05 01:12:13 +01:00
parent 04dd756217
commit d73980ded5
2 changed files with 8 additions and 3 deletions

View File

@ -92,7 +92,7 @@ if (Test-Network) {
#Get External ModsPath if System #Get External ModsPath if System
if ($WAUConfig.WAU_ModsPath) { if ($WAUConfig.WAU_ModsPath) {
Write-Log "WAU uses External Mods from: $($WAUConfig.WAU_ModsPath)" Write-Log "WAU uses External Mods from: $($WAUConfig.WAU_ModsPath)"
$NewMods = Test-ModsPath $WAUConfig.WAU_ModsPath $WAUConfig.InstallLocation $NewMods, $DeletedMods = Test-ModsPath $WAUConfig.WAU_ModsPath $WAUConfig.InstallLocation
if ($NewMods -gt 0) { if ($NewMods -gt 0) {
Write-Log "Newer Mods downloaded/copied to local path: $($WAUConfig.InstallLocation)\mods" "Yellow" Write-Log "Newer Mods downloaded/copied to local path: $($WAUConfig.InstallLocation)\mods" "Yellow"
} }
@ -104,6 +104,9 @@ if (Test-Network) {
Write-Log "No Mods are implemented..." "Yellow" Write-Log "No Mods are implemented..." "Yellow"
} }
} }
if ($DeletedMods -gt 0) {
Write-Log "Deleted Local Mods (not externally managed): $DeletedMods" "Green"
}
} }
} }

View File

@ -30,6 +30,7 @@ function Test-ModsPath ($ModsPath, $WingetUpdatePath) {
try { try {
If ($Mod -notin $ModLinks) { If ($Mod -notin $ModLinks) {
Remove-Item $LocalMods\$Mod -Force | Out-Null Remove-Item $LocalMods\$Mod -Force | Out-Null
$DeletedMods++
} }
} }
catch { catch {
@ -65,7 +66,7 @@ function Test-ModsPath ($ModsPath, $WingetUpdatePath) {
} }
} }
} }
return $ModsUpdated return $ModsUpdated, $DeletedMods
} }
# If path is UNC or local # If path is UNC or local
else { else {
@ -77,6 +78,7 @@ function Test-ModsPath ($ModsPath, $WingetUpdatePath) {
try { try {
If($Mod -notin $ExternalModsNames ){ If($Mod -notin $ExternalModsNames ){
Remove-Item $LocalMods\$Mod -Force | Out-Null Remove-Item $LocalMods\$Mod -Force | Out-Null
$DeletedMods++
} }
} }
catch { catch {
@ -104,7 +106,7 @@ function Test-ModsPath ($ModsPath, $WingetUpdatePath) {
catch { catch {
return $False return $False
} }
return $ModsUpdated return $ModsUpdated, $DeletedMods
} }
} }
return $False return $False