diff options
author | Chocobozzz <me@florianbigard.com> | 2021-12-03 09:52:03 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-12-03 10:14:17 +0100 |
commit | ca87d95bcbfec9241e5840267862bace8b0197fa (patch) | |
tree | 8cc01322ac3140e0ab191770cae0e03b84ab2bb9 /server/lib/plugins | |
parent | 8406a9e8eec261e563d99c92f8a18b6bd3e46e0f (diff) | |
download | PeerTube-ca87d95bcbfec9241e5840267862bace8b0197fa.tar.gz PeerTube-ca87d95bcbfec9241e5840267862bace8b0197fa.tar.zst PeerTube-ca87d95bcbfec9241e5840267862bace8b0197fa.zip |
Fix plugin upgrade
Correctly decache all plugin paths
Diffstat (limited to 'server/lib/plugins')
-rw-r--r-- | server/lib/plugins/plugin-manager.ts | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/server/lib/plugins/plugin-manager.ts b/server/lib/plugins/plugin-manager.ts index d4d2a7edc..8add72a85 100644 --- a/server/lib/plugins/plugin-manager.ts +++ b/server/lib/plugins/plugin-manager.ts | |||
@@ -1,8 +1,8 @@ | |||
1 | import decache from 'decache' | ||
2 | import express from 'express' | 1 | import express from 'express' |
3 | import { createReadStream, createWriteStream } from 'fs' | 2 | import { createReadStream, createWriteStream } from 'fs' |
4 | import { ensureDir, outputFile, readJSON } from 'fs-extra' | 3 | import { ensureDir, outputFile, readJSON } from 'fs-extra' |
5 | import { basename, join } from 'path' | 4 | import { basename, join } from 'path' |
5 | import { decachePlugin } from '@server/helpers/decache' | ||
6 | import { MOAuthTokenUser, MUser } from '@server/types/models' | 6 | import { MOAuthTokenUser, MUser } from '@server/types/models' |
7 | import { getCompleteLocale } from '@shared/core-utils' | 7 | import { getCompleteLocale } from '@shared/core-utils' |
8 | import { ClientScript, PluginPackageJson, PluginTranslation, PluginTranslationPaths, RegisterServerHookOptions } from '@shared/models' | 8 | import { ClientScript, PluginPackageJson, PluginTranslation, PluginTranslationPaths, RegisterServerHookOptions } from '@shared/models' |
@@ -312,12 +312,12 @@ export class PluginManager implements ServerHook { | |||
312 | logger.error('Cannot install plugin %s, removing it...', toInstall, { err: rootErr }) | 312 | logger.error('Cannot install plugin %s, removing it...', toInstall, { err: rootErr }) |
313 | 313 | ||
314 | try { | 314 | try { |
315 | await this.uninstall(npmName) | 315 | // await this.uninstall(npmName) |
316 | } catch (err) { | 316 | } catch (err) { |
317 | logger.error('Cannot uninstall plugin %s after failed installation.', toInstall, { err }) | 317 | logger.error('Cannot uninstall plugin %s after failed installation.', toInstall, { err }) |
318 | 318 | ||
319 | try { | 319 | try { |
320 | await removeNpmPlugin(npmName) | 320 | // await removeNpmPlugin(npmName) |
321 | } catch (err) { | 321 | } catch (err) { |
322 | logger.error('Cannot remove plugin %s after failed installation.', toInstall, { err }) | 322 | logger.error('Cannot remove plugin %s after failed installation.', toInstall, { err }) |
323 | } | 323 | } |
@@ -420,7 +420,7 @@ export class PluginManager implements ServerHook { | |||
420 | 420 | ||
421 | // Delete cache if needed | 421 | // Delete cache if needed |
422 | const modulePath = join(pluginPath, packageJSON.library) | 422 | const modulePath = join(pluginPath, packageJSON.library) |
423 | decache(modulePath) | 423 | decachePlugin(pluginPath, modulePath) |
424 | const library: PluginLibrary = require(modulePath) | 424 | const library: PluginLibrary = require(modulePath) |
425 | 425 | ||
426 | if (!isLibraryCodeValid(library)) { | 426 | if (!isLibraryCodeValid(library)) { |