From: Chocobozzz Date: Tue, 6 Jun 2023 09:59:27 +0000 (+0200) Subject: Correctly unload plugin paths X-Git-Tag: v5.2.0~35 X-Git-Url: https://git.immae.eu/?a=commitdiff_plain;h=07880c3642ca9fd9363850cf1a8e3cd2c6d9cd59;hp=25d7cc3cb675de36fe67402e307e1ba02f3316bc;p=github%2FChocobozzz%2FPeerTube.git Correctly unload plugin paths --- diff --git a/server/helpers/decache.ts b/server/helpers/decache.ts index 08ab545e4..6be446ff6 100644 --- a/server/helpers/decache.ts +++ b/server/helpers/decache.ts @@ -3,16 +3,16 @@ import { extname } from 'path' -function decachePlugin (pluginPath: string, libraryPath: string) { +function decachePlugin (libraryPath: string) { const moduleName = find(libraryPath) if (!moduleName) return searchCache(moduleName, function (mod) { delete require.cache[mod.id] - }) - removeCachedPath(pluginPath) + removeCachedPath(mod.path) + }) } function decacheModule (name: string) { @@ -22,9 +22,9 @@ function decacheModule (name: string) { searchCache(moduleName, function (mod) { delete require.cache[mod.id] - }) - removeCachedPath(moduleName) + removeCachedPath(mod.path) + }) } // --------------------------------------------------------------------------- diff --git a/server/lib/plugins/plugin-manager.ts b/server/lib/plugins/plugin-manager.ts index 9086a4c8e..88c5b60d7 100644 --- a/server/lib/plugins/plugin-manager.ts +++ b/server/lib/plugins/plugin-manager.ts @@ -496,7 +496,7 @@ export class PluginManager implements ServerHook { // Delete cache if needed const modulePath = join(pluginPath, packageJSON.library) - decachePlugin(pluginPath, modulePath) + decachePlugin(modulePath) const library: PluginLibrary = require(modulePath) if (!isLibraryCodeValid(library)) {