Refactor Update-Scripts function to enhance condition checks for file existence
This commit is contained in:
@@ -59,7 +59,7 @@ function Update-Scripts {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Check if the download was successful (file exists and is not empty)
|
# Check if the download was successful (file exists and is not empty)
|
||||||
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 {
|
try {
|
||||||
@@ -70,7 +70,7 @@ function Update-Scripts {
|
|||||||
# Find the extracted directory
|
# Find the extracted directory
|
||||||
$extractedDir = Get-ChildItem -Path $tempDir -Directory | Select-Object -First 1
|
$extractedDir = Get-ChildItem -Path $tempDir -Directory | Select-Object -First 1
|
||||||
|
|
||||||
if ($extractedDir -and (Test-Path $extractedDir.FullName)) {
|
if (($extractedDir) -and ((Test-Path $extractedDir.FullName))) {
|
||||||
# Copy all files except .git directory to current location
|
# Copy all files except .git directory to current location
|
||||||
Write-Host "Installing updates..." -ForegroundColor Cyan
|
Write-Host "Installing updates..." -ForegroundColor Cyan
|
||||||
Get-ChildItem -Path $extractedDir.FullName | Where-Object { $_.Name -ne ".git" } | ForEach-Object {
|
Get-ChildItem -Path $extractedDir.FullName | Where-Object { $_.Name -ne ".git" } | ForEach-Object {
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ function Update-Scripts {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Check if the download was successful (file exists and is not empty)
|
# Check if the download was successful (file exists and is not empty)
|
||||||
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 {
|
try {
|
||||||
@@ -70,7 +70,7 @@ function Update-Scripts {
|
|||||||
# Find the extracted directory
|
# Find the extracted directory
|
||||||
$extractedDir = Get-ChildItem -Path $tempDir -Directory | Select-Object -First 1
|
$extractedDir = Get-ChildItem -Path $tempDir -Directory | Select-Object -First 1
|
||||||
|
|
||||||
if ($extractedDir -and (Test-Path $extractedDir.FullName)) {
|
if (($extractedDir) -and ((Test-Path $extractedDir.FullName))) {
|
||||||
# Copy all files except .git directory to current location
|
# Copy all files except .git directory to current location
|
||||||
Write-Host "Installing updates..." -ForegroundColor Cyan
|
Write-Host "Installing updates..." -ForegroundColor Cyan
|
||||||
Get-ChildItem -Path $extractedDir.FullName | Where-Object { $_.Name -ne ".git" } | ForEach-Object {
|
Get-ChildItem -Path $extractedDir.FullName | Where-Object { $_.Name -ne ".git" } | ForEach-Object {
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ function Update-Scripts {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Check if the download was successful (file exists and is not empty)
|
# Check if the download was successful (file exists and is not empty)
|
||||||
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 {
|
try {
|
||||||
@@ -70,7 +70,7 @@ function Update-Scripts {
|
|||||||
# Find the extracted directory
|
# Find the extracted directory
|
||||||
$extractedDir = Get-ChildItem -Path $tempDir -Directory | Select-Object -First 1
|
$extractedDir = Get-ChildItem -Path $tempDir -Directory | Select-Object -First 1
|
||||||
|
|
||||||
if ($extractedDir -and (Test-Path $extractedDir.FullName)) {
|
if (($extractedDir) -and ((Test-Path $extractedDir.FullName))) {
|
||||||
# Copy all files except .git directory to current location
|
# Copy all files except .git directory to current location
|
||||||
Write-Host "Installing updates..." -ForegroundColor Cyan
|
Write-Host "Installing updates..." -ForegroundColor Cyan
|
||||||
Get-ChildItem -Path $extractedDir.FullName | Where-Object { $_.Name -ne ".git" } | ForEach-Object {
|
Get-ChildItem -Path $extractedDir.FullName | Where-Object { $_.Name -ne ".git" } | ForEach-Object {
|
||||||
|
|||||||
Reference in New Issue
Block a user