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

@@ -2,16 +2,19 @@ import { replaceConfigFile } from "../config/config.js";
import type { OpenClawConfig } from "../config/types.openclaw.js";
import type { PluginInstallRecord } from "../config/types.plugins.js";
import {
loadInstalledPluginIndexInstallRecords,
PLUGIN_INSTALLS_CONFIG_PATH,
writePersistedInstalledPluginIndexInstallRecords,
} from "../plugins/installed-plugin-index-records.js";
export async function commitPluginInstallRecordsWithConfig(params: {
previousInstallRecords: Record<string, PluginInstallRecord>;
previousInstallRecords?: Record<string, PluginInstallRecord>;
nextInstallRecords: Record<string, PluginInstallRecord>;
nextConfig: OpenClawConfig;
baseHash?: string;
}): Promise<void> {
const previousInstallRecords =
params.previousInstallRecords ?? (await loadInstalledPluginIndexInstallRecords());
await writePersistedInstalledPluginIndexInstallRecords(params.nextInstallRecords);
try {
await replaceConfigFile({
@@ -21,7 +24,7 @@ export async function commitPluginInstallRecordsWithConfig(params: {
});
} catch (error) {
try {
await writePersistedInstalledPluginIndexInstallRecords(params.previousInstallRecords);
await writePersistedInstalledPluginIndexInstallRecords(previousInstallRecords);
} catch (rollbackError) {
throw new Error(
"Failed to commit plugin install records and could not restore the previous plugin index",