From d587ddbb196a61c49f7edc941479b0a9ee416ebe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A8=8B=E5=BA=8F=E5=91=98=E9=98=BF=E6=B1=9F=28Relakkes?= =?UTF-8?q?=29?= Date: Tue, 14 Jul 2026 05:15:30 +0800 Subject: [PATCH] fix(desktop): filter empty installer paths --- desktop/build/recover-legacy-install-data.ps1 | 10 +++++++--- scripts/pr/release-workflow.test.ts | 2 ++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/desktop/build/recover-legacy-install-data.ps1 b/desktop/build/recover-legacy-install-data.ps1 index dd2d6d49..664a2063 100644 --- a/desktop/build/recover-legacy-install-data.ps1 +++ b/desktop/build/recover-legacy-install-data.ps1 @@ -635,7 +635,7 @@ function Write-AppModeAtomically { function Invoke-LegacyRecovery { param( - [Parameter(Mandatory = $true)][string[]]$InstallDirs, + [Parameter(Mandatory = $true)][AllowEmptyCollection()][AllowEmptyString()][string[]]$InstallDirs, [AllowEmptyCollection()][AllowEmptyString()][string[]]$SharedInstallDirs = @(), [Parameter(Mandatory = $true)][string]$UserDataDir, [Parameter(Mandatory = $true)][string]$RecoveryRoot, @@ -646,7 +646,11 @@ function Invoke-LegacyRecovery { [switch]$SkipProcessCheck ) - $potentialInstallDirs = @(Get-PotentialInstallDirs -InstallDirs $InstallDirs) + $installDirInputs = @($InstallDirs | Where-Object { -not [string]::IsNullOrWhiteSpace($_) }) + if ($installDirInputs.Count -eq 0) { + return $null + } + $potentialInstallDirs = @(Get-PotentialInstallDirs -InstallDirs $installDirInputs) $existingInstallDirs = @(Get-ExistingInstallDirs -InstallDirs $potentialInstallDirs) if ($existingInstallDirs.Count -eq 0) { return $null @@ -809,7 +813,7 @@ function Run-SelfTest { New-Item -ItemType Directory -Path $perUserExternalTarget -Force | Out-Null New-Item -ItemType Junction -Path $perUserAppPayload -Target $perUserExternalTarget | Out-Null $perUserResult = Invoke-LegacyRecovery ` - -InstallDirs @($perUserInstall) -SharedInstallDirs @('') ` + -InstallDirs @('', $perUserInstall, '') -SharedInstallDirs @('') ` -UserDataDir (Join-Path $testRoot 'per-user app data') ` -RecoveryRoot (Join-Path $testRoot 'per-user recovery') -ProcessName $ProcessName ` -ActiveConfigDir '' -SkipProcessCheck diff --git a/scripts/pr/release-workflow.test.ts b/scripts/pr/release-workflow.test.ts index 8e86d14c..e92bfccd 100644 --- a/scripts/pr/release-workflow.test.ts +++ b/scripts/pr/release-workflow.test.ts @@ -532,6 +532,8 @@ describe('release desktop workflow', () => { expect(recoveryHelper).toContain('Active CLAUDE_CONFIG_DIR is managed outside Claude Code Haha') expect(recoveryHelper).toContain('Test-LexicalPathAtOrBelow') expect(recoveryHelper).toContain('-SharedInstallDirs @($PerMachineInstallDir)') + expect(recoveryHelper).toContain("function Invoke-LegacyRecovery {\n param(\n [Parameter(Mandatory = $true)][AllowEmptyCollection()][AllowEmptyString()][string[]]$InstallDirs") + expect(recoveryHelper).toContain('$installDirInputs.Count -eq 0') expect(recoveryHelper).toContain('$sharedInstallDirInputs.Count -gt 0') expect(recoveryHelper).toContain('per-user default-mode reinstall scanned the packaged application tree') expect(recoveryHelper).toContain('untrusted-elevated')