From 5b1aad2dc25d51400003508881d43b69266ab661 Mon Sep 17 00:00:00 2001 From: tigattack <10629864+tigattack@users.noreply.github.com> Date: Sun, 20 Aug 2023 17:42:45 +0100 Subject: [PATCH] fix(installer): improve existing installation detection/handling --- Installer.ps1 | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Installer.ps1 b/Installer.ps1 index 59bd979..9276d32 100644 --- a/Installer.ps1 +++ b/Installer.ps1 @@ -75,11 +75,17 @@ Write-Output @' '@ # Check if this project is already installed and if so, exit -if (Test-Path "$InstallParentPath\$project") { +if (Test-Path "$InstallParentPath\$project\resources\version.txt") { $installedVersion = (Get-Content -Raw "$InstallParentPath\$project\resources\version.txt").Trim() Write-Output "`n$project ($installedVersion) is already installed. This script cannot update an existing installation." Write-Output "Please manually update or delete/rename the existing installation and retry.`n`n" - exit + exit 1 +} +elseif ((Test-Path "$InstallParentPath\$project") -and (Get-ChildItem "$InstallParentPath\$project").Count -gt 0) { + "`nThe install path ($InstallParentPath\$project) already exists with children, " ` + + "but an existing installation couldn't be detected (looking for $InstallParentPath\$project\resources\version.txt)." | Write-Output + Write-Output "Please remove the install path and retry.`n`n" + exit 1 } If ($Version -and $Version -notmatch '^v(\d+\.)?(\d+\.)?(\*|\d+)$') {