Skip to content

Commit

Permalink
chore(plugins): gracefully handle plugin update failure
Browse files Browse the repository at this point in the history
Upon an failed update, rollback to the previous version.
  • Loading branch information
kontrollanten committed Jun 19, 2024
1 parent 298f5f0 commit 38b0c31
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions server/core/lib/plugins/plugin-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -429,12 +429,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: {
Expand Down

0 comments on commit 38b0c31

Please sign in to comment.