fix: surface and recover from silent plugin re-enable failures after update
reloadPlugin() previously swallowed disablePlugin/enablePlugin exceptions unless debuggingMode was on, and the update path always reported success regardless of whether the reload actually worked. This let auto-updated plugins (most often actively-developed ones like BindThem, since only a real version bump exercises the reload path) end up silently disabled after a background update, with no error and a false 'Updated' notice. Now reloadPlugin() returns success/failure, always logs the error, retries once via enablePluginAndSave as a fallback, and the update notice reflects the real outcome so a failed re-enable is visible instead of silent.
This commit is contained in:
1 parent
aacee9ddcd
commit
02bd051359
3 files changed
+28
-8
No files matched your search
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"id": "obsidian42-brat-gitea",
|
"id": "obsidian42-brat-gitea",
|
||||||
"name": "BRAT (Gitea Fork)",
|
"name": "BRAT (Gitea Fork)",
|
||||||
"version": "1.0.0",
|
"version": "1.0.1",
|
||||||
"minAppVersion": "1.11.4",
|
"minAppVersion": "1.11.4",
|
||||||
"description": "Easily install beta plugins from GitHub AND self-hosted Gitea/Forgejo instances.",
|
"description": "Easily install beta plugins from GitHub AND self-hosted Gitea/Forgejo instances.",
|
||||||
"author": "TfTHacker (Gitea fork)",
|
"author": "TfTHacker (Gitea fork)",
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "obsidian42-brat-gitea",
|
"name": "obsidian42-brat-gitea",
|
||||||
"version": "1.0.0",
|
"version": "1.0.1",
|
||||||
"description": "BRAT fork with Gitea support — install beta plugins from GitHub or self-hosted Gitea/Forgejo.",
|
"description": "BRAT fork with Gitea support — install beta plugins from GitHub or self-hosted Gitea/Forgejo.",
|
||||||
"main": "main.js",
|
"main": "main.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -641,11 +641,13 @@ export default class BetaPlugins {
|
|||||||
);
|
);
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
await this.plugin.app.plugins.loadManifests();
|
await this.plugin.app.plugins.loadManifests();
|
||||||
await this.reloadPlugin(primaryManifest.id);
|
const reloaded = await this.reloadPlugin(primaryManifest.id);
|
||||||
const msg = `${primaryManifest.id}\nUpdated: ${localManifestJson.version} → ${primaryManifest.version}. `;
|
const msg = reloaded
|
||||||
|
? `${primaryManifest.id}\nUpdated: ${localManifestJson.version} → ${primaryManifest.version}. `
|
||||||
|
: `${primaryManifest.id}\nUpdated files to ${primaryManifest.version}, but failed to re-enable automatically. Enable it manually in Community Plugins.`;
|
||||||
await this.plugin.log(msg, true);
|
await this.plugin.log(msg, true);
|
||||||
toastMessage(this.plugin, msg, 30);
|
toastMessage(this.plugin, msg, reloaded ? 30 : 0);
|
||||||
return true;
|
return reloaded;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (reportIfNotUpdated) {
|
if (reportIfNotUpdated) {
|
||||||
@@ -669,14 +671,32 @@ export default class BetaPlugins {
|
|||||||
/**
|
/**
|
||||||
* reloads a plugin
|
* reloads a plugin
|
||||||
*/
|
*/
|
||||||
async reloadPlugin(pluginName: string): Promise<void> {
|
async reloadPlugin(pluginName: string): Promise<boolean> {
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
const { plugins } = this.plugin.app;
|
const { plugins } = this.plugin.app;
|
||||||
try {
|
try {
|
||||||
await plugins.disablePlugin(pluginName);
|
await plugins.disablePlugin(pluginName);
|
||||||
await plugins.enablePlugin(pluginName);
|
await plugins.enablePlugin(pluginName);
|
||||||
|
return true;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (this.plugin.settings.debuggingMode) console.log("reload plugin", e);
|
const errorMessage = e instanceof Error ? e.message : String(e);
|
||||||
|
console.error(`BRAT: Failed to reload plugin ${pluginName}`, e);
|
||||||
|
await this.plugin.log(
|
||||||
|
`Failed to reload ${pluginName} after update: ${errorMessage}`,
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
try {
|
||||||
|
await plugins.enablePluginAndSave(pluginName);
|
||||||
|
return true;
|
||||||
|
} catch (e2) {
|
||||||
|
const fallbackMessage = e2 instanceof Error ? e2.message : String(e2);
|
||||||
|
console.error(`BRAT: Fallback re-enable failed for ${pluginName}`, e2);
|
||||||
|
await this.plugin.log(
|
||||||
|
`Fallback re-enable also failed for ${pluginName}: ${fallbackMessage}`,
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user