fix(desktop): skip legacy recovery on fresh install

This commit is contained in:
程序员阿江(Relakkes) 2026-07-14 04:31:01 +08:00
parent d5be1f824a
commit 406f603015
2 changed files with 51 additions and 23 deletions

View File

@ -6,6 +6,10 @@ Var pid
!ifndef BUILD_UNINSTALLER !ifndef BUILD_UNINSTALLER
Var ccHahaRecoveryDone Var ccHahaRecoveryDone
Var ccHahaPerUserInstallLocation
Var ccHahaPerMachineInstallLocation
Var ccHahaPerUserUninstallString
Var ccHahaPerMachineUninstallString
Function CcHahaUninstallerParent Function CcHahaUninstallerParent
Exch $R0 Exch $R0
@ -155,6 +159,26 @@ FunctionEnd
!macro CcHahaRunLegacyRecovery !macro CcHahaRunLegacyRecovery
${If} $ccHahaRecoveryDone != "1" ${If} $ccHahaRecoveryDone != "1"
ReadRegStr $ccHahaPerUserInstallLocation HKCU "${INSTALL_REGISTRY_KEY}" InstallLocation
ReadRegStr $ccHahaPerMachineInstallLocation HKLM "${INSTALL_REGISTRY_KEY}" InstallLocation
ReadRegStr $ccHahaPerUserUninstallString HKCU "${UNINSTALL_REGISTRY_KEY}" UninstallString
ReadRegStr $ccHahaPerMachineUninstallString HKLM "${UNINSTALL_REGISTRY_KEY}" UninstallString
!ifdef UNINSTALL_REGISTRY_KEY_2
${If} $ccHahaPerUserUninstallString == ""
ReadRegStr $ccHahaPerUserUninstallString HKCU "${UNINSTALL_REGISTRY_KEY_2}" UninstallString
${EndIf}
${If} $ccHahaPerMachineUninstallString == ""
ReadRegStr $ccHahaPerMachineUninstallString HKLM "${UNINSTALL_REGISTRY_KEY_2}" UninstallString
${EndIf}
!endif
${If} $ccHahaPerUserInstallLocation == ""
${AndIf} $ccHahaPerMachineInstallLocation == ""
${AndIf} $ccHahaPerUserUninstallString == ""
${AndIf} $ccHahaPerMachineUninstallString == ""
StrCpy $ccHahaRecoveryDone "1"
DetailPrint "No registered installation needs legacy data recovery"
${Else}
StrCpy $8 "trusted-user" StrCpy $8 "trusted-user"
${If} ${UAC_IsAdmin} ${If} ${UAC_IsAdmin}
${AndIfNot} ${UAC_IsInnerInstance} ${AndIfNot} ${UAC_IsInnerInstance}
@ -181,6 +205,7 @@ FunctionEnd
StrCpy $ccHahaRecoveryDone "1" StrCpy $ccHahaRecoveryDone "1"
DetailPrint "Legacy Claude Code Haha data safety check completed" DetailPrint "Legacy Claude Code Haha data safety check completed"
${EndIf} ${EndIf}
${EndIf}
!macroend !macroend
!endif !endif

View File

@ -510,6 +510,9 @@ describe('release desktop workflow', () => {
expect(installerHook).toContain('ReadEnvStr $6 CLAUDE_CONFIG_DIR') expect(installerHook).toContain('ReadEnvStr $6 CLAUDE_CONFIG_DIR')
expect(installerHook).toContain('ReadEnvStr $7 CC_HAHA_APP_PORTABLE_DIR') expect(installerHook).toContain('ReadEnvStr $7 CC_HAHA_APP_PORTABLE_DIR')
expect(installerHook).toContain('No registered installation needs legacy data recovery') expect(installerHook).toContain('No registered installation needs legacy data recovery')
expect(installerHook).toContain('Var ccHahaPerUserInstallLocation')
expect(installerHook).toContain('Var ccHahaPerMachineInstallLocation')
expect(installerHook).toMatch(/!macro CcHahaRunLegacyRecovery[\s\S]*ReadRegStr \$ccHahaPerUserInstallLocation[\s\S]*\$ccHahaPerUserUninstallString == ""[\s\S]*No registered installation needs legacy data recovery[\s\S]*Call CcHahaRecoverLegacy/)
expect(installerHook).toContain('SetErrorLevel 20') expect(installerHook).toContain('SetErrorLevel 20')
expect(installerHook).toContain('Quit') expect(installerHook).toContain('Quit')
expect(recoveryHelper).toContain('function Get-LegacyActiveSource') expect(recoveryHelper).toContain('function Get-LegacyActiveSource')