Skip to content

Commit

Permalink
Avoid Local File Deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
KnifMelti committed Nov 29, 2024
1 parent e31afa8 commit 2a685f2
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Sources/Winget-AutoUpdate/functions/Test-ListPath.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function Test-ListPath ($ListPath, $UseWhiteList, $WingetUpdatePath) {
try {
$wc.OpenRead("$ExternalList").Close() | Out-Null
$dateExternal = ([DateTime]$wc.ResponseHeaders['Last-Modified']).ToString("yyyy-MM-dd HH:mm:ss")
if ($dateExternal -gt $dateLocal) {
if ($dateExternal -and $dateExternal -gt $dateLocal) {
try {
$wc.DownloadFile($ExternalList, $LocalList)
}
Expand All @@ -54,6 +54,7 @@ function Test-ListPath ($ListPath, $UseWhiteList, $WingetUpdatePath) {
}
catch {
try {
$wc.OpenRead("$ExternalList").Close() | Out-Null
$wc.DownloadFile($ExternalList, $LocalList)
$Script:AlwaysDownloaded = $True
return $true
Expand Down

0 comments on commit 2a685f2

Please sign in to comment.