mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 10:00:42 +00:00
perf(plugins): reuse persisted registry fallback read
This commit is contained in:
@@ -309,6 +309,13 @@ describe("plugin registry facade", () => {
|
||||
policyHash: resolveInstalledPluginIndexPolicyHash({
|
||||
plugins: { entries: { persisted: { enabled: true } } },
|
||||
}),
|
||||
installRecords: {
|
||||
persisted: {
|
||||
source: "npm",
|
||||
spec: "persisted-plugin@1.0.0",
|
||||
installPath: path.join(stateDir, "plugins", "persisted"),
|
||||
},
|
||||
},
|
||||
}),
|
||||
{ stateDir },
|
||||
);
|
||||
@@ -329,6 +336,12 @@ describe("plugin registry facade", () => {
|
||||
expect(listPluginRecords({ index: result.snapshot }).map((plugin) => plugin.pluginId)).toEqual([
|
||||
"demo",
|
||||
]);
|
||||
expect(result.snapshot.installRecords).toMatchObject({
|
||||
persisted: {
|
||||
source: "npm",
|
||||
spec: "persisted-plugin@1.0.0",
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it("falls back to the derived registry when the persisted registry is missing", () => {
|
||||
|
||||
@@ -326,12 +326,13 @@ export function loadPluginRegistrySnapshotWithMetadata(
|
||||
const disabledByCaller = params.preferPersisted === false;
|
||||
const disabledByEnv = hasEnvFlag(env, DISABLE_PERSISTED_PLUGIN_REGISTRY_ENV);
|
||||
const persistedReadsEnabled = !disabledByCaller && !disabledByEnv;
|
||||
let persistedIndex: InstalledPluginIndex | null = null;
|
||||
if (persistedReadsEnabled) {
|
||||
const persisted = readPersistedInstalledPluginIndexSync(params);
|
||||
if (persisted) {
|
||||
persistedIndex = readPersistedInstalledPluginIndexSync(params);
|
||||
if (persistedIndex) {
|
||||
if (
|
||||
params.config &&
|
||||
persisted.policyHash !== resolveInstalledPluginIndexPolicyHash(params.config)
|
||||
persistedIndex.policyHash !== resolveInstalledPluginIndexPolicyHash(params.config)
|
||||
) {
|
||||
diagnostics.push({
|
||||
level: "warn",
|
||||
@@ -341,7 +342,7 @@ export function loadPluginRegistrySnapshotWithMetadata(
|
||||
});
|
||||
} else {
|
||||
return {
|
||||
snapshot: persisted,
|
||||
snapshot: persistedIndex,
|
||||
source: "persisted",
|
||||
diagnostics,
|
||||
};
|
||||
@@ -368,9 +369,7 @@ export function loadPluginRegistrySnapshotWithMetadata(
|
||||
...params,
|
||||
installRecords:
|
||||
params.installRecords ??
|
||||
extractPluginInstallRecordsFromInstalledPluginIndex(
|
||||
persistedReadsEnabled ? readPersistedInstalledPluginIndexSync(params) : null,
|
||||
),
|
||||
extractPluginInstallRecordsFromInstalledPluginIndex(persistedIndex),
|
||||
}),
|
||||
source: "derived",
|
||||
diagnostics,
|
||||
|
||||
Reference in New Issue
Block a user