fix(desktop): filter empty installer paths

This commit is contained in:
程序员阿江(Relakkes) 2026-07-14 05:15:30 +08:00
parent 73a4aef95f
commit d587ddbb19
2 changed files with 9 additions and 3 deletions

View File

@ -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

View File

@ -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')