fix(desktop): skip empty shared install scans

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

View File

@ -636,7 +636,7 @@ function Write-AppModeAtomically {
function Invoke-LegacyRecovery { function Invoke-LegacyRecovery {
param( param(
[Parameter(Mandatory = $true)][string[]]$InstallDirs, [Parameter(Mandatory = $true)][string[]]$InstallDirs,
[string[]]$SharedInstallDirs = @(), [AllowEmptyCollection()][AllowEmptyString()][string[]]$SharedInstallDirs = @(),
[Parameter(Mandatory = $true)][string]$UserDataDir, [Parameter(Mandatory = $true)][string]$UserDataDir,
[Parameter(Mandatory = $true)][string]$RecoveryRoot, [Parameter(Mandatory = $true)][string]$RecoveryRoot,
[Parameter(Mandatory = $true)][string]$ProcessName, [Parameter(Mandatory = $true)][string]$ProcessName,
@ -657,8 +657,12 @@ function Invoke-LegacyRecovery {
-UserDataDir $UserDataDir ` -UserDataDir $UserDataDir `
-ActiveConfigDir $ActiveConfigDir ` -ActiveConfigDir $ActiveConfigDir `
-ActiveConfigManaged $ActiveConfigManaged -ActiveConfigManaged $ActiveConfigManaged
$potentialSharedInstallDirs = @(Get-PotentialInstallDirs -InstallDirs $SharedInstallDirs) $sharedInstallDirInputs = @($SharedInstallDirs | Where-Object { -not [string]::IsNullOrWhiteSpace($_) })
$existingSharedInstallDirs = @()
if ($sharedInstallDirInputs.Count -gt 0) {
$potentialSharedInstallDirs = @(Get-PotentialInstallDirs -InstallDirs $sharedInstallDirInputs)
$existingSharedInstallDirs = @(Get-ExistingInstallDirs -InstallDirs $potentialSharedInstallDirs) $existingSharedInstallDirs = @(Get-ExistingInstallDirs -InstallDirs $potentialSharedInstallDirs)
}
if ($existingSharedInstallDirs.Count -gt 0) { if ($existingSharedInstallDirs.Count -gt 0) {
Assert-NoUndiscoveredLegacySources -InstallDirs $existingSharedInstallDirs -ActiveSource $source Assert-NoUndiscoveredLegacySources -InstallDirs $existingSharedInstallDirs -ActiveSource $source
} }

View File

@ -532,6 +532,7 @@ describe('release desktop workflow', () => {
expect(recoveryHelper).toContain('Active CLAUDE_CONFIG_DIR is managed outside Claude Code Haha') expect(recoveryHelper).toContain('Active CLAUDE_CONFIG_DIR is managed outside Claude Code Haha')
expect(recoveryHelper).toContain('Test-LexicalPathAtOrBelow') expect(recoveryHelper).toContain('Test-LexicalPathAtOrBelow')
expect(recoveryHelper).toContain('-SharedInstallDirs @($PerMachineInstallDir)') expect(recoveryHelper).toContain('-SharedInstallDirs @($PerMachineInstallDir)')
expect(recoveryHelper).toContain('$sharedInstallDirInputs.Count -gt 0')
expect(recoveryHelper).toContain('per-user default-mode reinstall scanned the packaged application tree') expect(recoveryHelper).toContain('per-user default-mode reinstall scanned the packaged application tree')
expect(recoveryHelper).toContain('untrusted-elevated') expect(recoveryHelper).toContain('untrusted-elevated')
expect(recoveryHelper).toContain('External CLAUDE_CONFIG_DIR is active while install-contained legacy data still exists') expect(recoveryHelper).toContain('External CLAUDE_CONFIG_DIR is active while install-contained legacy data still exists')