Optimized $dateLocal

pull/166/head
KnifMelti 2022-09-19 23:55:07 +02:00
parent ec73a55fe4
commit 515bdfd0a5
1 changed files with 1 additions and 3 deletions

View File

@ -9,6 +9,7 @@ function Test-ListPath ($ListPath, $UseWhiteList) {
$ListType="excluded" $ListType="excluded"
} }
$LocalList = -join($WingetUpdatePath, "\", $ListType, "_apps.txt") $LocalList = -join($WingetUpdatePath, "\", $ListType, "_apps.txt")
$dateLocal = (Get-Item "$LocalList").LastWriteTime.ToString("yyyy-MM-dd HH:mm:ss")
$PathInfo=[System.Uri]$ListPath $PathInfo=[System.Uri]$ListPath
if($PathInfo.IsUnc){ if($PathInfo.IsUnc){
@ -16,7 +17,6 @@ function Test-ListPath ($ListPath, $UseWhiteList) {
$ExternalList = -join($ListPath, "\", $ListType, "_apps.txt") $ExternalList = -join($ListPath, "\", $ListType, "_apps.txt")
if(Test-Path -Path $ExternalList -PathType leaf){ if(Test-Path -Path $ExternalList -PathType leaf){
Write-Output "Given path $ListPath type is $PathType and $ExternalList is available..." Write-Output "Given path $ListPath type is $PathType and $ExternalList is available..."
$dateLocal = (Get-Item "$LocalList").LastWriteTime.ToString("yyyy-MM-dd HH:mm:ss")
$dateExternal = (Get-Item "$ListPath").LastWriteTime.ToString("yyyy-MM-dd HH:mm:ss") $dateExternal = (Get-Item "$ListPath").LastWriteTime.ToString("yyyy-MM-dd HH:mm:ss")
if ($dateExternal -gt $dateLocal) { if ($dateExternal -gt $dateLocal) {
Write-Host("$ExternalList is newer than $LocalList") Write-Host("$ExternalList is newer than $LocalList")
@ -33,7 +33,6 @@ function Test-ListPath ($ListPath, $UseWhiteList) {
try { try {
$wc.OpenRead("$ExternalList").Close() | Out-Null $wc.OpenRead("$ExternalList").Close() | Out-Null
Write-Output "Given path $ListPath type is $PathType and $ExternalList is available..." Write-Output "Given path $ListPath type is $PathType and $ExternalList is available..."
$dateLocal = (Get-Item "$LocalList").LastWriteTime.ToString("yyyy-MM-dd HH:mm:ss")
$dateExternal = ([DateTime]$wc.ResponseHeaders['Last-Modified']).ToString("yyyy-MM-dd HH:mm:ss") $dateExternal = ([DateTime]$wc.ResponseHeaders['Last-Modified']).ToString("yyyy-MM-dd HH:mm:ss")
if ($dateExternal -gt $dateLocal) { if ($dateExternal -gt $dateLocal) {
Write-Host("$ExternalList is newer than $LocalList") Write-Host("$ExternalList is newer than $LocalList")
@ -48,7 +47,6 @@ function Test-ListPath ($ListPath, $UseWhiteList) {
$ExternalList = -join($ListPath, "\", $ListType, "_apps.txt") $ExternalList = -join($ListPath, "\", $ListType, "_apps.txt")
if(Test-Path -Path $ExternalList -PathType leaf){ if(Test-Path -Path $ExternalList -PathType leaf){
Write-Output "Given path $ListPath type is $PathType and $ExternalList is available..." Write-Output "Given path $ListPath type is $PathType and $ExternalList is available..."
$dateLocal = (Get-Item "$LocalList").LastWriteTime.ToString("yyyy-MM-dd HH:mm:ss")
$dateExternal = (Get-Item "$ListPath").LastWriteTime.ToString("yyyy-MM-dd HH:mm:ss") $dateExternal = (Get-Item "$ListPath").LastWriteTime.ToString("yyyy-MM-dd HH:mm:ss")
if ($dateExternal -gt $dateLocal) { if ($dateExternal -gt $dateLocal) {
Write-Host("$ExternalList is newer than $LocalList") Write-Host("$ExternalList is newer than $LocalList")