chore(plugins): gracefully handle plugin update failure

Upon an failed update, rollback to the previous version.
This commit is contained in:
kontrollanten 2024-06-19 16:48:47 +02:00
parent 3870d6349f
commit 014cdb5981

View File

@ -427,12 +427,19 @@ export class PluginManager implements ServerHook {
// Use the latest version from DB, to not upgrade to a version that does not support our PeerTube version
let version: string
const plugin = await PluginModel.loadByNpmName(toUpdate)
if (!fromDisk) {
const plugin = await PluginModel.loadByNpmName(toUpdate)
version = plugin.latestVersion
}
return this.install({ toInstall: toUpdate, version, fromDisk })
try {
return this.install({ toInstall: toUpdate, version, fromDisk })
} catch (err) {
logger.info('Reinstalling last installed version.', { err })
return this.install({ toInstall: toUpdate, version: plugin.version })
}
}
async uninstall (options: {