






















@@ -1,3 +1,5 @@
1+import { existsSync } from "node:fs";
2+import path from "node:path";
13import {
24listExplicitlyDisabledChannelIdsForConfig,
35listPotentialConfiguredChannelIds,
@@ -24,6 +26,7 @@ import type { PluginMetadataSnapshot } from "../../../plugins/plugin-metadata-sn
2426import { resolveProviderInstallCatalogEntries } from "../../../plugins/provider-install-catalog.js";
2527import { updateNpmInstalledPlugins } from "../../../plugins/update.js";
2628import { resolveWebSearchInstallCatalogEntry } from "../../../plugins/web-search-install-catalog.js";
29+import { resolveUserPath } from "../../../utils.js";
2730import { asObjectRecord } from "./object.js";
28312932type DownloadableInstallCandidate = {
@@ -290,6 +293,18 @@ function collectConfiguredPluginIdsWithMissingChannelConfigDescriptors(params: {
290293return stalePluginIds;
291294}
292295296+function isInstalledRecordMissingOnDisk(
297+record: PluginInstallRecord | undefined,
298+env: NodeJS.ProcessEnv,
299+): boolean {
300+const installPath = record?.installPath?.trim();
301+if (!installPath) {
302+return true;
303+}
304+const resolved = resolveUserPath(installPath, env);
305+return !existsSync(path.join(resolved, "package.json"));
306+}
307+293308async function installCandidate(params: {
294309candidate: DownloadableInstallCandidate;
295310records: Record<string, PluginInstallRecord>;
@@ -445,7 +460,8 @@ async function repairMissingPluginInstalls(params: {
445460const records = await loadInstalledPluginIndexInstallRecords({ env });
446461const missingRecordedPluginIds = Object.keys(records).filter(
447462(pluginId) =>
448-(params.pluginIds.has(pluginId) && !knownIds.has(pluginId)) ||
463+(params.pluginIds.has(pluginId) &&
464+(!knownIds.has(pluginId) || isInstalledRecordMissingOnDisk(records[pluginId], env))) ||
449465configuredPluginIdsWithStaleDescriptors.has(pluginId),
450466);
451467const changes: string[] = [];
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。