diff options
author | Chocobozzz <me@florianbigard.com> | 2021-06-30 11:45:06 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-06-30 11:45:20 +0200 |
commit | 9c2e051c56e1ef6b9c9901f492fb506ee5d16def (patch) | |
tree | ba9d731b0e3d89e2a3004c047c59c0c4e4e7bac0 /server/lib/plugins/plugin-manager.ts | |
parent | 4c0a6954fb6df177f842de4bf3e3a97eb171a11b (diff) | |
download | PeerTube-9c2e051c56e1ef6b9c9901f492fb506ee5d16def.tar.gz PeerTube-9c2e051c56e1ef6b9c9901f492fb506ee5d16def.tar.zst PeerTube-9c2e051c56e1ef6b9c9901f492fb506ee5d16def.zip |
Handle broken plugin install
Diffstat (limited to 'server/lib/plugins/plugin-manager.ts')
-rw-r--r-- | server/lib/plugins/plugin-manager.ts | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/server/lib/plugins/plugin-manager.ts b/server/lib/plugins/plugin-manager.ts index 6b9a255a4..6599bccca 100644 --- a/server/lib/plugins/plugin-manager.ts +++ b/server/lib/plugins/plugin-manager.ts | |||
@@ -304,22 +304,28 @@ export class PluginManager implements ServerHook { | |||
304 | uninstalled: false, | 304 | uninstalled: false, |
305 | peertubeEngine: packageJSON.engine.peertube | 305 | peertubeEngine: packageJSON.engine.peertube |
306 | }, { returning: true }) | 306 | }, { returning: true }) |
307 | } catch (err) { | 307 | |
308 | logger.error('Cannot install plugin %s, removing it...', toInstall, { err }) | 308 | logger.info('Successful installation of plugin %s.', toInstall) |
309 | |||
310 | await this.registerPluginOrTheme(plugin) | ||
311 | } catch (rootErr) { | ||
312 | logger.error('Cannot install plugin %s, removing it...', toInstall, { err: rootErr }) | ||
309 | 313 | ||
310 | try { | 314 | try { |
311 | await removeNpmPlugin(npmName) | 315 | await this.uninstall(npmName) |
312 | } catch (err) { | 316 | } catch (err) { |
313 | logger.error('Cannot remove plugin %s after failed installation.', toInstall, { err }) | 317 | logger.error('Cannot uninstall plugin %s after failed installation.', toInstall, { err }) |
318 | |||
319 | try { | ||
320 | await removeNpmPlugin(npmName) | ||
321 | } catch (err) { | ||
322 | logger.error('Cannot remove plugin %s after failed installation.', toInstall, { err }) | ||
323 | } | ||
314 | } | 324 | } |
315 | 325 | ||
316 | throw err | 326 | throw rootErr |
317 | } | 327 | } |
318 | 328 | ||
319 | logger.info('Successful installation of plugin %s.', toInstall) | ||
320 | |||
321 | await this.registerPluginOrTheme(plugin) | ||
322 | |||
323 | return plugin | 329 | return plugin |
324 | } | 330 | } |
325 | 331 | ||
@@ -425,8 +431,7 @@ export class PluginManager implements ServerHook { | |||
425 | 431 | ||
426 | await ensureDir(registerOptions.peertubeHelpers.plugin.getDataDirectoryPath()) | 432 | await ensureDir(registerOptions.peertubeHelpers.plugin.getDataDirectoryPath()) |
427 | 433 | ||
428 | library.register(registerOptions) | 434 | await library.register(registerOptions) |
429 | .catch(err => logger.error('Cannot register plugin %s.', npmName, { err })) | ||
430 | 435 | ||
431 | logger.info('Add plugin %s CSS to global file.', npmName) | 436 | logger.info('Add plugin %s CSS to global file.', npmName) |
432 | 437 | ||