1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-04 10:19:35 +02:00

Handle broken plugin install

This commit is contained in:
Chocobozzz 2021-06-30 11:45:06 +02:00
parent 4c0a6954fb
commit 9c2e051c56
No known key found for this signature in database
GPG key ID: 583A612D890159BE
4 changed files with 80 additions and 11 deletions

View file

@ -304,22 +304,28 @@ export class PluginManager implements ServerHook {
uninstalled: false,
peertubeEngine: packageJSON.engine.peertube
}, { returning: true })
} catch (err) {
logger.error('Cannot install plugin %s, removing it...', toInstall, { err })
logger.info('Successful installation of plugin %s.', toInstall)
await this.registerPluginOrTheme(plugin)
} catch (rootErr) {
logger.error('Cannot install plugin %s, removing it...', toInstall, { err: rootErr })
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 })
}
}
throw err
throw rootErr
}
logger.info('Successful installation of plugin %s.', toInstall)
await this.registerPluginOrTheme(plugin)
return plugin
}
@ -425,8 +431,7 @@ export class PluginManager implements ServerHook {
await ensureDir(registerOptions.peertubeHelpers.plugin.getDataDirectoryPath())
library.register(registerOptions)
.catch(err => logger.error('Cannot register plugin %s.', npmName, { err }))
await library.register(registerOptions)
logger.info('Add plugin %s CSS to global file.', npmName)