fix: reinstall missing plugin folders with enableAfterInstall honored
Tatortreiniger / tatort-reinigen (release) Has been cancelled
Tatortreiniger / tatort-reinigen (release) Has been cancelled
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.
This commit is contained in:
1 parent
f69790c2f9
commit
91247d31e2
3 files changed
+20
-22
No files matched your search
+18
-20
@@ -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(
|
||||
|
||||
Reference in new issue
Block a user