mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 13:00:45 +00:00
fix: roll back plugin index for update channel writes
This commit is contained in:
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user