Files
msime-windows/installer/tests/cloud-choice-probe.iss
luo jiyinandfanlusky acc25f40e6 fix(installer): 在最终数据目录保存云候选选择 (#972)
* fix(installer): 在最终数据目录保存云候选选择

安装器在数据目录确定后检查已有配置。升级迁移遇到配置冲突时停止,避免覆盖目标配置。

首次安装以 UTF-8 写入云候选选择,并在写入失败时报告错误。

增加安装时序检查和 Windows 安装测试矩阵。

Refs #931

* test(installer): 用 Inno 探针验证云候选配置写回

主安装器与探针共用云候选配置函数。

Windows CI 执行五个隔离的首次安装和升级场景。

Refs #931

* test(installer): 接受 Inno 配置文件的 CRLF 行尾

测试按完整的 cloud_candidates 行检查结果。失败时打印实际字段值。

Refs #931

* fix(installer): check config migration conflict before stopping IME

* test(installer): clear expected conflict exit code

* test(installer): narrow source check to migration order

* fix(installer): 云候选写回失败不再中断安装,迁移可重试

- 写回「不启用云候选」失败时只记日志并提示,挪到必需的安装后步骤之后
- 两处 config.toml 内容相同时视为上次迁移的残留,允许重试
- config.toml 没搬过去时中止安装,避免新目录装上出厂配置
- 数据目录页就检查配置冲突
- ShouldSkipPage 不再写全局状态
- 探针复用生产的迁移判断与顺序,补齐改目录首次安装、重试和迁移失败场景

---------

Co-authored-by: fanlusky <1730976608@qq.com>
2026-10-15 23:00:34 +08:00

74 lines
2.3 KiB
Plaintext

[Setup]
AppId=MsimeCloudChoiceProbe
AppName=MsimeCloudChoiceProbe
AppVersion=1
DefaultDirName={localappdata}\MsimeCloudChoiceProbe
PrivilegesRequired=lowest
CreateUninstallRegKey=no
Uninstallable=no
OutputBaseFilename=cloud-choice-probe
Compression=none
DisableProgramGroupPage=yes
[Files]
Source: "..\default_config\config.default.toml"; DestDir: "{param:TARGET}"; DestName: "config.toml"; Flags: onlyifdoesntexist
[Code]
var
NetworkPage: TInputOptionWizardPage;
CloudCandidatesIndex: Integer;
UserConfigExistedBeforeInstall: Boolean;
function GetDataDir(Param: String): String;
begin
Result := ExpandConstant('{param:TARGET|}');
end;
function ResolvePreviousDataDir: String;
begin
Result := ExpandConstant('{param:PREVIOUS|}');
end;
function UserConfigPath: String;
begin
Result := AddBackslash(GetDataDir('')) + 'config.toml';
end;
#include "../cloud_choice.iss"
procedure InitializeWizard;
begin
NetworkPage := CreateInputOptionPage(wpWelcome, 'Network', 'Network', 'Network', False, False);
CloudCandidatesIndex := NetworkPage.Add('Cloud candidates');
NetworkPage.Values[CloudCandidatesIndex] := ExpandConstant('{param:CLOUD|1}') <> '0';
end;
{ 与 msime_setup.iss 的 PrepareToInstall / MigrateUserDataDir 同序:先记下配置是否已存在,
再查冲突,然后用同样的 robocopy /MOVE 搬 config.toml,失败时用同一个函数判断要不要中止。}
function PrepareToInstall(var NeedsRestart: Boolean): String;
var
OldDir, NewDir: String;
ResultCode: Integer;
begin
OldDir := ResolvePreviousDataDir;
NewDir := GetDataDir('');
UserConfigExistedBeforeInstall := UserConfigExistsBeforeInstall;
Result := ConfigMigrationProblem(OldDir, NewDir);
if (Result <> '') or (OldDir = '') or (CompareText(OldDir, NewDir) = 0) or
(not DirExists(OldDir)) then
Exit;
ForceDirectories(NewDir);
DropMigratedConfigCopy(OldDir, NewDir);
if not (Exec(
ExpandConstant('{sys}\robocopy.exe'),
'"' + OldDir + '" "' + NewDir + '" config.toml /MOVE /R:0 /W:0 /NJH /NJS /NP /NFL /NDL',
'', SW_HIDE, ewWaitUntilTerminated, ResultCode) and (ResultCode < 8)) then
Result := ConfigMigrationFailure(OldDir, NewDir);
end;
procedure CurStepChanged(CurStep: TSetupStep);
begin
if CurStep = ssPostInstall then
ApplyNetworkChoiceToUserConfig;
end;