aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2023-05-05 14:14:26 +0200
committerChocobozzz <me@florianbigard.com>2023-05-05 14:24:27 +0200
commit841ddf8886f87ee694b604d2d0948326a6f9b4bb (patch)
tree0c1941b9132ae5352e276d85b668ec0f65e2df2a /server/lib
parent257fa0d1a06b0110335ca53fb6cd341b6759fa5a (diff)
downloadPeerTube-841ddf8886f87ee694b604d2d0948326a6f9b4bb.tar.gz
PeerTube-841ddf8886f87ee694b604d2d0948326a6f9b4bb.tar.zst
PeerTube-841ddf8886f87ee694b604d2d0948326a6f9b4bb.zip
Don't call plugin register/unregister methods
Diffstat (limited to 'server/lib')
-rw-r--r--server/lib/plugins/plugin-manager.ts34
1 files changed, 25 insertions, 9 deletions
diff --git a/server/lib/plugins/plugin-manager.ts b/server/lib/plugins/plugin-manager.ts
index d368aecfc..ca7275366 100644
--- a/server/lib/plugins/plugin-manager.ts
+++ b/server/lib/plugins/plugin-manager.ts
@@ -325,7 +325,14 @@ export class PluginManager implements ServerHook {
325 325
326 // ###################### Installation ###################### 326 // ###################### Installation ######################
327 327
328 async install (toInstall: string, version?: string, fromDisk = false) { 328 async install (options: {
329 toInstall: string
330 version?: string
331 fromDisk?: boolean // default false
332 register?: boolean // default true
333 }) {
334 const { toInstall, version, fromDisk = false, register = true } = options
335
329 let plugin: PluginModel 336 let plugin: PluginModel
330 let npmName: string 337 let npmName: string
331 338
@@ -357,12 +364,14 @@ export class PluginManager implements ServerHook {
357 364
358 logger.info('Successful installation of plugin %s.', toInstall) 365 logger.info('Successful installation of plugin %s.', toInstall)
359 366
360 await this.registerPluginOrTheme(plugin) 367 if (register) {
368 await this.registerPluginOrTheme(plugin)
369 }
361 } catch (rootErr) { 370 } catch (rootErr) {
362 logger.error('Cannot install plugin %s, removing it...', toInstall, { err: rootErr }) 371 logger.error('Cannot install plugin %s, removing it...', toInstall, { err: rootErr })
363 372
364 try { 373 try {
365 await this.uninstall(npmName) 374 await this.uninstall({ npmName })
366 } catch (err) { 375 } catch (err) {
367 logger.error('Cannot uninstall plugin %s after failed installation.', toInstall, { err }) 376 logger.error('Cannot uninstall plugin %s after failed installation.', toInstall, { err })
368 377
@@ -394,16 +403,23 @@ export class PluginManager implements ServerHook {
394 // Unregister old hooks 403 // Unregister old hooks
395 await this.unregister(npmName) 404 await this.unregister(npmName)
396 405
397 return this.install(toUpdate, version, fromDisk) 406 return this.install({ toInstall: toUpdate, version, fromDisk })
398 } 407 }
399 408
400 async uninstall (npmName: string) { 409 async uninstall (options: {
410 npmName: string
411 unregister?: boolean // default true
412 }) {
413 const { npmName, unregister } = options
414
401 logger.info('Uninstalling plugin %s.', npmName) 415 logger.info('Uninstalling plugin %s.', npmName)
402 416
403 try { 417 if (unregister) {
404 await this.unregister(npmName) 418 try {
405 } catch (err) { 419 await this.unregister(npmName)
406 logger.warn('Cannot unregister plugin %s.', npmName, { err }) 420 } catch (err) {
421 logger.warn('Cannot unregister plugin %s.', npmName, { err })
422 }
407 } 423 }
408 424
409 const plugin = await PluginModel.loadByNpmName(npmName) 425 const plugin = await PluginModel.loadByNpmName(npmName)