












@@ -1,4 +1,3 @@
1-import fs from "node:fs";
21import path from "node:path";
32import { MANIFEST_KEY } from "../../compat/legacy-names.js";
43import type { PluginInstallRecord } from "../../config/types.plugins.js";
@@ -77,13 +76,8 @@ type ExternalCatalogEntry = {
77767877const ENV_CATALOG_PATHS = ["OPENCLAW_PLUGIN_CATALOG_PATHS", "OPENCLAW_MPM_CATALOG_PATHS"];
7978const OFFICIAL_CHANNEL_CATALOG_RELATIVE_PATH = path.join("dist", "channel-catalog.json");
80-type CatalogEntriesCacheEntry = {
81-fingerprint: string;
82-entries: ExternalCatalogEntry[] | null;
83-};
84-8579const officialCatalogEntriesByPath = new Map<string, ExternalCatalogEntry[] | null>();
86-const externalCatalogEntriesByPath = new Map<string, CatalogEntriesCacheEntry>();
80+const externalCatalogEntriesByPath = new Map<string, ExternalCatalogEntry[] | null>();
87818882type ManifestKey = typeof MANIFEST_KEY;
8983@@ -143,36 +137,26 @@ function loadExternalCatalogEntries(options: CatalogOptions): ExternalCatalogEnt
143137return loadCatalogEntriesFromPaths(paths, externalCatalogEntriesByPath);
144138}
145139146-function fingerprintCatalogPath(filePath: string): string {
147-try {
148-const stat = fs.statSync(filePath, { bigint: true });
149-const kind = stat.isFile() ? "file" : stat.isDirectory() ? "dir" : "other";
150-return [kind, stat.size.toString(), stat.mtimeNs.toString(), stat.ctimeNs.toString()].join(":");
151-} catch {
152-return "missing";
153-}
154-}
155-156140function readCatalogEntriesFromPath(resolvedPath: string): ExternalCatalogEntry[] | null {
157141const payload = tryReadJsonSync(resolvedPath);
158142return payload === null ? null : parseCatalogEntries(payload);
159143}
160144161145function loadCatalogEntriesFromPaths(
162146paths: Iterable<string>,
163-cache?: Map<string, CatalogEntriesCacheEntry>,
147+cache?: Map<string, ExternalCatalogEntry[] | null>,
164148): ExternalCatalogEntry[] {
165149const entries: ExternalCatalogEntry[] = [];
166150for (const resolvedPath of paths) {
167-const fingerprint = cache ? fingerprintCatalogPath(resolvedPath) : undefined;
168-const cached = fingerprint ? cache?.get(resolvedPath) : undefined;
169-const parsed =
170-cached && cached.fingerprint === fingerprint
171- ? cached.entries
172- : readCatalogEntriesFromPath(resolvedPath);
173-if (cache && fingerprint) {
174-cache.set(resolvedPath, { fingerprint, entries: parsed });
151+if (cache?.has(resolvedPath)) {
152+const cached = cache.get(resolvedPath);
153+if (cached) {
154+entries.push(...cached);
155+}
156+continue;
175157}
158+const parsed = readCatalogEntriesFromPath(resolvedPath);
159+cache?.set(resolvedPath, parsed);
176160if (parsed === null) {
177161continue;
178162}
此內容由慣性聚合(RSS閱讀器)自動聚合整理,僅供閱讀參考。 原文來自 — 版權歸原作者所有。