X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Flib%2Fplugins%2Fplugin-manager.ts;h=03ea48416b7ab65f8e9d0d60d63f31d59c09eb69;hb=8280d0c22797c72978f698dc2deaa8ef569a9d15;hp=0086a0e2e42af9c78afaf86ee44430bca66c2998;hpb=09d535ef9817a63096dc724cc4d9f0671ee6e5a3;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/lib/plugins/plugin-manager.ts b/server/lib/plugins/plugin-manager.ts index 0086a0e2e..03ea48416 100644 --- a/server/lib/plugins/plugin-manager.ts +++ b/server/lib/plugins/plugin-manager.ts @@ -1,3 +1,4 @@ +import decache from 'decache' import * as express from 'express' import { createReadStream, createWriteStream } from 'fs' import { outputFile, readJSON } from 'fs-extra' @@ -23,8 +24,6 @@ import { ClientHtml } from '../client-html' import { RegisterHelpers } from './register-helpers' import { installNpmPlugin, installNpmPluginFromDisk, removeNpmPlugin } from './yarn' -const decache = require('decache') - export interface RegisteredPlugin { npmName: string name: string @@ -329,11 +328,18 @@ export class PluginManager implements ServerHook { return plugin } - async update (toUpdate: string, version?: string, fromDisk = false) { + async update (toUpdate: string, fromDisk = false) { const npmName = fromDisk ? basename(toUpdate) : toUpdate logger.info('Updating plugin %s.', npmName) + // Use the latest version from DB, to not upgrade to a version that does not support our PeerTube version + let version: string + if (!fromDisk) { + const plugin = await PluginModel.loadByNpmName(toUpdate) + version = plugin.latestVersion + } + // Unregister old hooks await this.unregister(npmName)