From f86ff3a02642263ac64db5d5fba4059db0092561 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 17 May 2023 16:19:30 +0200 Subject: [PATCH] Prevent uninstall error on install error --- server/lib/plugins/plugin-manager.ts | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/server/lib/plugins/plugin-manager.ts b/server/lib/plugins/plugin-manager.ts index eab0b3978..9086a4c8e 100644 --- a/server/lib/plugins/plugin-manager.ts +++ b/server/lib/plugins/plugin-manager.ts @@ -370,15 +370,17 @@ export class PluginManager implements ServerHook { } catch (rootErr) { logger.error('Cannot install plugin %s, removing it...', toInstall, { err: rootErr }) - try { - await this.uninstall({ npmName }) - } catch (err) { - logger.error('Cannot uninstall plugin %s after failed installation.', toInstall, { err }) - + if (npmName) { try { - await removeNpmPlugin(npmName) + await this.uninstall({ npmName }) } catch (err) { - logger.error('Cannot remove plugin %s after failed installation.', toInstall, { err }) + logger.error('Cannot uninstall plugin %s after failed installation.', toInstall, { err }) + + try { + await removeNpmPlugin(npmName) + } catch (err) { + logger.error('Cannot remove plugin %s after failed installation.', toInstall, { err }) + } } } -- 2.41.0