fix: roll back plugin index for update channel writes

This commit is contained in:
Shakker
2026-04-26 01:24:56 +01:00
parent 41282fcb13
commit e7c131d6de
7 changed files with 78 additions and 67 deletions

View File

@@ -44,9 +44,7 @@ import {
import { runGatewayUpdate, type UpdateRunResult } from "../../infra/update-runner.js";
import {
loadInstalledPluginIndexInstallRecords,
PLUGIN_INSTALLS_CONFIG_PATH,
withoutPluginInstallRecords,
writePersistedInstalledPluginIndexInstallRecords,
withPluginInstallRecords,
} from "../../plugins/installed-plugin-index-records.js";
import { syncPluginsForUpdateChannel, updateNpmInstalledPlugins } from "../../plugins/update.js";
@@ -64,6 +62,7 @@ import {
terminateStaleGatewayPids,
waitForGatewayHealthyRestart,
} from "../daemon-cli/restart-health.js";
import { commitPluginInstallRecordsWithConfig } from "../plugins-install-record-commit.js";
import { listPersistedBundledPluginLocationBridges } from "../plugins-location-bridges.js";
import { refreshPluginRegistryAfterConfigMutation } from "../plugins-registry-refresh.js";
import { createUpdateProgress, printResult } from "./progress.js";
@@ -628,17 +627,19 @@ async function updatePluginsAfterCoreUpdate(params: {
pluginConfig = npmResult.config;
if (syncResult.changed || npmResult.changed) {
await writePersistedInstalledPluginIndexInstallRecords(pluginConfig.plugins?.installs ?? {});
const nextInstallRecords = pluginConfig.plugins?.installs ?? {};
const nextConfig = withoutPluginInstallRecords(pluginConfig);
await replaceConfigFile({
await commitPluginInstallRecordsWithConfig({
previousInstallRecords: pluginInstallRecords,
nextInstallRecords,
nextConfig,
baseHash: params.configSnapshot.hash,
writeOptions: { unsetPaths: [Array.from(PLUGIN_INSTALLS_CONFIG_PATH)] },
});
await refreshPluginRegistryAfterConfigMutation({
config: nextConfig,
reason: "source-changed",
workspaceDir: params.root,
installRecords: nextInstallRecords,
logger: pluginLogger,
});
}