fix(updates): apply deferred component updates when package downloaded

This commit is contained in:
zipg authored and GitHub committed 2026-09-21 11:38:54 +08:00
1 parent 6c0de607f4
commit d3b3a4dbd6
2 files changed
+17

No files matched your search

+9
View File
@@ -1317,6 +1317,15 @@ async function updateAllAvailable() {
reportComponentUpdateResult(await componentUpdates.installCategories(categories));
return;
}
if (action === "defer-components") {
const remembered = await rememberComponentUpdatesForRestartedApp({ kind: "manual", categories });
if (remembered) {
toast(t("settings.updateRestartHint"), 6000);
return;
}
reportComponentUpdateResult(await componentUpdates.installCategories(categories));
return;
}
if (action === "download-app") await downloadUpdateInBackground();
if (updateDownloaded.value || updateReady.value) await rememberComponentUpdatesForRestartedApp({ kind: "manual", categories });
} finally {
@@ -79,6 +79,14 @@ describe("component update orchestration", () => {
expect(resolveUpdateAllAction({ hasAppUpdate: true, appUpdateCanInstall: true, appUpdatePrepared: true, hasComponentUpdates: true })).toBe("defer-components");
});
it("persists the selected component categories when the DBX package is already prepared", () => {
const action = resolveUpdateAllAction({ hasAppUpdate: true, appUpdateCanInstall: true, appUpdatePrepared: true, hasComponentUpdates: true });
expect(action).toBe("defer-components");
expect(markPendingComponentUpdatesAfterAppUpdate("0.6.16", "0.6.17", { kind: "manual", categories: ["drivers", "mcp"] })).toBe(true);
expect(takePendingComponentUpdatesAfterAppRestart("0.6.17")?.plan).toEqual({ kind: "manual", categories: ["drivers", "mcp"] });
});
it("updates components immediately when no DBX update exists or the package cannot be installed", () => {
expect(resolveUpdateAllAction({ hasAppUpdate: false, appUpdateCanInstall: true, appUpdatePrepared: false, hasComponentUpdates: true })).toBe("update-components");
expect(resolveUpdateAllAction({ hasAppUpdate: true, appUpdateCanInstall: false, appUpdatePrepared: false, hasComponentUpdates: true })).toBe("update-components");