mirror of https://github.com/Chocobozzz/PeerTube
Correctly unload plugin paths
parent
25d7cc3cb6
commit
07880c3642
|
@ -3,16 +3,16 @@
|
||||||
|
|
||||||
import { extname } from 'path'
|
import { extname } from 'path'
|
||||||
|
|
||||||
function decachePlugin (pluginPath: string, libraryPath: string) {
|
function decachePlugin (libraryPath: string) {
|
||||||
const moduleName = find(libraryPath)
|
const moduleName = find(libraryPath)
|
||||||
|
|
||||||
if (!moduleName) return
|
if (!moduleName) return
|
||||||
|
|
||||||
searchCache(moduleName, function (mod) {
|
searchCache(moduleName, function (mod) {
|
||||||
delete require.cache[mod.id]
|
delete require.cache[mod.id]
|
||||||
})
|
|
||||||
|
|
||||||
removeCachedPath(pluginPath)
|
removeCachedPath(mod.path)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function decacheModule (name: string) {
|
function decacheModule (name: string) {
|
||||||
|
@ -22,9 +22,9 @@ function decacheModule (name: string) {
|
||||||
|
|
||||||
searchCache(moduleName, function (mod) {
|
searchCache(moduleName, function (mod) {
|
||||||
delete require.cache[mod.id]
|
delete require.cache[mod.id]
|
||||||
})
|
|
||||||
|
|
||||||
removeCachedPath(moduleName)
|
removeCachedPath(mod.path)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
|
@ -496,7 +496,7 @@ export class PluginManager implements ServerHook {
|
||||||
|
|
||||||
// Delete cache if needed
|
// Delete cache if needed
|
||||||
const modulePath = join(pluginPath, packageJSON.library)
|
const modulePath = join(pluginPath, packageJSON.library)
|
||||||
decachePlugin(pluginPath, modulePath)
|
decachePlugin(modulePath)
|
||||||
const library: PluginLibrary = require(modulePath)
|
const library: PluginLibrary = require(modulePath)
|
||||||
|
|
||||||
if (!isLibraryCodeValid(library)) {
|
if (!isLibraryCodeValid(library)) {
|
||||||
|
|
Loading…
Reference in New Issue