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