Done, ISS must be confed to handle ++ in filename!

pull/257/head
KnifMelti 2023-01-04 18:56:07 +01:00
parent 4b0165b7e7
commit a248215c64
1 changed files with 7 additions and 38 deletions

View File

@ -40,17 +40,20 @@ function Test-ModsPath ($ModsPath, $WingetUpdatePath) {
$DeletedMods = 0
# 0 is the parent HTTP Directory
$index = 1
$CleanLinks = $ModLinks -replace "/.*/",""
foreach ($Mod in $InternalModsNames) {
If ($ModLinks -notcontains "$Mod") {
If ($CleanLinks -notcontains "$Mod") {
Remove-Item $LocalMods\$Mod -Force -ErrorAction SilentlyContinue | Out-Null
$DeletedMods++
}
$index++
}
$CleanLinks = $ModLinks -replace "/.*/",""
#Loop through all links
$wc = New-Object System.Net.WebClient
$WebResponse.Links | Select-Object -ExpandProperty href | ForEach-Object {
$CleanLinks | ForEach-Object {
#Check for .ps1/.txt in listing/HREF:s in an index page pointing to .ps1/.txt
if (($_ -like "*.ps1") -or ($_ -like "*.txt")) {
try {
@ -81,38 +84,4 @@ function Test-ModsPath ($ModsPath, $WingetUpdatePath) {
}
return $ModsUpdated, $DeletedMods
}
# If path is UNC or local
else {
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
foreach ($Mod in $InternalModsNames){
If($Mod -notin $ExternalModsNames ){
Remove-Item $LocalMods\$Mod -Force -ErrorAction SilentlyContinue | Out-Null
$DeletedMods++
}
}
try {
foreach ($Mod in $ExternalModsNames){
$dateExternalMod = ""
$dateLocalMod =""
if (Test-Path -Path $LocalMods"\"$Mod) {
$dateLocalMod = (Get-Item "$LocalMods\$Mod").LastWriteTime.ToString("yyyy-MM-dd HH:mm:ss")
}
$dateExternalMod = (Get-Item "$ExternalMods\$Mod").LastWriteTime.ToString("yyyy-MM-dd HH:mm:ss")
if ($dateExternalMod -gt $dateLocalMod) {
Copy-Item $ExternalMods\$Mod -Destination $LocalMods\$Mod -Force -ErrorAction SilentlyContinue | Out-Null
$ModsUpdated++
}
}
}
catch {
return $False
}
return $ModsUpdated, $DeletedMods
}
return $False
}
}