From 91247d31e2f053aa2d3e1cbedf2b8aea64f2836c Mon Sep 17 00:00:00 2001 From: Olivier Date: Mon, 5 Oct 2026 09:48:10 -0400 Subject: [PATCH] fix: reinstall missing plugin folders with enableAfterInstall honored When a managed plugin's folder was empty/missing at update time, BRAT reinstalled it via updatePlugin(), which hard-codes enableAfterInstall=false, so the plugin came back on disk but stayed disabled until toggled by hand. Detect absence with adapter.exists() (the errno check was desktop-only) and pass the user's enableAfterInstall setting to the fresh install. --- manifest.json | 2 +- package.json | 2 +- src/features/BetaPlugins.ts | 38 ++++++++++++++++++------------------- 3 files changed, 20 insertions(+), 22 deletions(-) diff --git a/manifest.json b/manifest.json index 7fe06b2..a5a2766 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "obsidian42-brat-gitea", "name": "BRAT (Gitea Fork)", - "version": "1.0.1", + "version": "1.0.2", "minAppVersion": "1.11.4", "description": "Easily install beta plugins from GitHub AND self-hosted Gitea/Forgejo instances.", "author": "TfTHacker (Gitea fork)", diff --git a/package.json b/package.json index 5932de3..e5bcb71 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "obsidian42-brat-gitea", - "version": "1.0.1", + "version": "1.0.2", "description": "BRAT fork with Gitea support — install beta plugins from GitHub or self-hosted Gitea/Forgejo.", "main": "main.js", "scripts": { diff --git a/src/features/BetaPlugins.ts b/src/features/BetaPlugins.ts index b783069..76aa2da 100644 --- a/src/features/BetaPlugins.ts +++ b/src/features/BetaPlugins.ts @@ -579,28 +579,26 @@ export default class BetaPlugins { } else { // Update existing plugin const pluginTargetFolderPath = `${this.plugin.app.vault.configDir}/plugins/${primaryManifest.id}/`; - let localManifestContents = ""; - try { - localManifestContents = await this.plugin.app.vault.adapter.read( - `${pluginTargetFolderPath}manifest.json`, + const localManifestPath = `${pluginTargetFolderPath}manifest.json`; + const vaultAdapter = this.plugin.app.vault.adapter; + if (!(await vaultAdapter.exists(localManifestPath))) { + // Plugin folder is empty/missing (deleted by sync, by hand, ...). + // Reinstall it. updatePlugin() hard-codes enableAfterInstall=false + // for plain updates, which here would leave the plugin installed + // but disabled, so use the user's setting instead. + return await this.addPlugin( + repositoryPath, + false, + usingBetaManifest, + false, + specifyVersion, + false, + this.plugin.settings.enableAfterInstall, + secretName, ); - } catch (e) { - const err = e as { errno?: number }; - if (err.errno === -4058 || err.errno === -2) { - await this.addPlugin( - repositoryPath, - false, - usingBetaManifest, - false, - specifyVersion, - false, - enableAfterInstall, - secretName, - ); - return true; - } - console.log("BRAT - Local Manifest Load", primaryManifest.id, e); } + const localManifestContents = + await vaultAdapter.read(localManifestPath); if (specifyVersion !== "" && specifyVersion !== "latest") { toastMessage(