From 515bdfd0a59be8bd50dff5ee54024598411416c0 Mon Sep 17 00:00:00 2001 From: KnifMelti Date: Mon, 19 Sep 2022 23:55:07 +0200 Subject: [PATCH] Optimized $dateLocal --- Winget-AutoUpdate/functions/Test-ListPath.ps1 | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Winget-AutoUpdate/functions/Test-ListPath.ps1 b/Winget-AutoUpdate/functions/Test-ListPath.ps1 index a7eb71d..c472734 100644 --- a/Winget-AutoUpdate/functions/Test-ListPath.ps1 +++ b/Winget-AutoUpdate/functions/Test-ListPath.ps1 @@ -9,6 +9,7 @@ function Test-ListPath ($ListPath, $UseWhiteList) { $ListType="excluded" } $LocalList = -join($WingetUpdatePath, "\", $ListType, "_apps.txt") + $dateLocal = (Get-Item "$LocalList").LastWriteTime.ToString("yyyy-MM-dd HH:mm:ss") $PathInfo=[System.Uri]$ListPath if($PathInfo.IsUnc){ @@ -16,7 +17,6 @@ function Test-ListPath ($ListPath, $UseWhiteList) { $ExternalList = -join($ListPath, "\", $ListType, "_apps.txt") if(Test-Path -Path $ExternalList -PathType leaf){ 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") if ($dateExternal -gt $dateLocal) { Write-Host("$ExternalList is newer than $LocalList") @@ -33,7 +33,6 @@ function Test-ListPath ($ListPath, $UseWhiteList) { try { $wc.OpenRead("$ExternalList").Close() | Out-Null 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") if ($dateExternal -gt $dateLocal) { Write-Host("$ExternalList is newer than $LocalList") @@ -48,7 +47,6 @@ function Test-ListPath ($ListPath, $UseWhiteList) { $ExternalList = -join($ListPath, "\", $ListType, "_apps.txt") if(Test-Path -Path $ExternalList -PathType leaf){ 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") if ($dateExternal -gt $dateLocal) { Write-Host("$ExternalList is newer than $LocalList")