]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/lib/plugins/plugin-manager.ts
Prevent uninstall error on install error
[github/Chocobozzz/PeerTube.git] / server / lib / plugins / plugin-manager.ts
index ca72753663541507cf2329912dedcbfaff934190..9086a4c8e855b2343fb77ddb9f49262bd001a81b 100644 (file)
@@ -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 })
+          }
         }
       }
 
@@ -410,7 +412,7 @@ export class PluginManager implements ServerHook {
     npmName: string
     unregister?: boolean // default true
   }) {
-    const { npmName, unregister } = options
+    const { npmName, unregister = true } = options
 
     logger.info('Uninstalling plugin %s.', npmName)