Refactor Update-Scripts function to improve error handling and code structure
This commit is contained in:
@@ -62,6 +62,7 @@ function Update-Scripts {
|
|||||||
if (Test-Path $zipPath -and (Get-Item $zipPath).Length -gt 0) {
|
if (Test-Path $zipPath -and (Get-Item $zipPath).Length -gt 0) {
|
||||||
Write-Host "Download successful!" -ForegroundColor Green
|
Write-Host "Download successful!" -ForegroundColor Green
|
||||||
|
|
||||||
|
try {
|
||||||
# Extract the zip file
|
# Extract the zip file
|
||||||
Write-Host "Extracting update package..." -ForegroundColor Cyan
|
Write-Host "Extracting update package..." -ForegroundColor Cyan
|
||||||
Expand-Archive -Path $zipPath -DestinationPath $tempDir -Force
|
Expand-Archive -Path $zipPath -DestinationPath $tempDir -Force
|
||||||
@@ -115,6 +116,7 @@ function Update-Scripts {
|
|||||||
return $false # Update failed
|
return $false # Update failed
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# Call the update function at the beginning
|
# Call the update function at the beginning
|
||||||
$scriptUpdated = Update-Scripts
|
$scriptUpdated = Update-Scripts
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ function Update-Scripts {
|
|||||||
if (Test-Path $zipPath -and (Get-Item $zipPath).Length -gt 0) {
|
if (Test-Path $zipPath -and (Get-Item $zipPath).Length -gt 0) {
|
||||||
Write-Host "Download successful!" -ForegroundColor Green
|
Write-Host "Download successful!" -ForegroundColor Green
|
||||||
|
|
||||||
|
try {
|
||||||
# Extract the zip file
|
# Extract the zip file
|
||||||
Write-Host "Extracting update package..." -ForegroundColor Cyan
|
Write-Host "Extracting update package..." -ForegroundColor Cyan
|
||||||
Expand-Archive -Path $zipPath -DestinationPath $tempDir -Force
|
Expand-Archive -Path $zipPath -DestinationPath $tempDir -Force
|
||||||
@@ -115,6 +116,7 @@ function Update-Scripts {
|
|||||||
return $false # Update failed
|
return $false # Update failed
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# Call the update function at the beginning
|
# Call the update function at the beginning
|
||||||
$scriptUpdated = Update-Scripts
|
$scriptUpdated = Update-Scripts
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ function Update-Scripts {
|
|||||||
if (Test-Path $zipPath -and (Get-Item $zipPath).Length -gt 0) {
|
if (Test-Path $zipPath -and (Get-Item $zipPath).Length -gt 0) {
|
||||||
Write-Host "Download successful!" -ForegroundColor Green
|
Write-Host "Download successful!" -ForegroundColor Green
|
||||||
|
|
||||||
|
try {
|
||||||
# Extract the zip file
|
# Extract the zip file
|
||||||
Write-Host "Extracting update package..." -ForegroundColor Cyan
|
Write-Host "Extracting update package..." -ForegroundColor Cyan
|
||||||
Expand-Archive -Path $zipPath -DestinationPath $tempDir -Force
|
Expand-Archive -Path $zipPath -DestinationPath $tempDir -Force
|
||||||
|
|||||||
Reference in New Issue
Block a user