From b3716686c935d0ffc24ef9c2fa4ea5bb07580da9 Mon Sep 17 00:00:00 2001 From: Andy Li <1450947+andy1li@users.noreply.github.com> Date: Thu, 5 Mar 2026 16:23:01 +0900 Subject: [PATCH] Refactor installation script to use -LiteralPath for path checks and improve cleanup error handling. This enhances the robustness of directory operations and ensures warnings are displayed if cleanup fails. --- install.ps1 | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/install.ps1 b/install.ps1 index 3935284..924212b 100644 --- a/install.ps1 +++ b/install.ps1 @@ -40,7 +40,7 @@ try { tar -xzf $TarGzPath -C $TempDir - if (-not (Test-Path $InstallDir)) { + if (-not (Test-Path -LiteralPath $InstallDir)) { New-Item -ItemType Directory -Path $InstallDir -Force | Out-Null } @@ -62,7 +62,11 @@ try { Write-Host "" } finally { # Cleanup - if (Test-Path $TempDir) { - Remove-Item -Path $TempDir -Recurse -Force -ErrorAction SilentlyContinue + if (Test-Path -LiteralPath $TempDir) { + try { + Remove-Item -LiteralPath $TempDir -Recurse -Force -ErrorAction Stop + } catch { + Write-Host "Warning: couldn't clean up temporary folder: $TempDir" -ForegroundColor Yellow + } } }