aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-04-09 09:37:46 +0200
committerChocobozzz <me@florianbigard.com>2021-04-09 09:37:46 +0200
commitbae930372678692f94601d503eaf7deabaa82a3f (patch)
tree58dddd58c1a4fe994a41f858451d972e8cee0897
parent09d535ef9817a63096dc724cc4d9f0671ee6e5a3 (diff)
downloadPeerTube-bae930372678692f94601d503eaf7deabaa82a3f.tar.gz
PeerTube-bae930372678692f94601d503eaf7deabaa82a3f.tar.zst
PeerTube-bae930372678692f94601d503eaf7deabaa82a3f.zip
Also decache config
-rw-r--r--server/initializers/config.ts17
-rw-r--r--server/lib/plugins/plugin-manager.ts3
-rw-r--r--yarn.lock9
3 files changed, 19 insertions, 10 deletions
diff --git a/server/initializers/config.ts b/server/initializers/config.ts
index 93dd5ac04..4e15acd0d 100644
--- a/server/initializers/config.ts
+++ b/server/initializers/config.ts
@@ -1,12 +1,13 @@
1import * as bytes from 'bytes'
1import { IConfig } from 'config' 2import { IConfig } from 'config'
3import decache from 'decache'
2import { dirname, join } from 'path' 4import { dirname, join } from 'path'
5import { VideoRedundancyConfigFilter } from '@shared/models/redundancy/video-redundancy-config-filter.type'
6import { BroadcastMessageLevel } from '@shared/models/server'
3import { VideosRedundancyStrategy } from '../../shared/models' 7import { VideosRedundancyStrategy } from '../../shared/models'
8import { NSFWPolicyType } from '../../shared/models/videos/nsfw-policy.type'
4// Do not use barrels, remain constants as independent as possible 9// Do not use barrels, remain constants as independent as possible
5import { buildPath, parseBytes, parseDurationToMs, root } from '../helpers/core-utils' 10import { buildPath, parseBytes, parseDurationToMs, root } from '../helpers/core-utils'
6import { NSFWPolicyType } from '../../shared/models/videos/nsfw-policy.type'
7import * as bytes from 'bytes'
8import { VideoRedundancyConfigFilter } from '@shared/models/redundancy/video-redundancy-config-filter.type'
9import { BroadcastMessageLevel } from '@shared/models/server'
10 11
11// Use a variable to reload the configuration if we need 12// Use a variable to reload the configuration if we need
12let config: IConfig = require('config') 13let config: IConfig = require('config')
@@ -410,7 +411,7 @@ function buildVideosRedundancy (objs: any[]): VideosRedundancyStrategy[] {
410 411
411export function reloadConfig () { 412export function reloadConfig () {
412 413
413 function directory () { 414 function getConfigDirectory () {
414 if (process.env.NODE_CONFIG_DIR) { 415 if (process.env.NODE_CONFIG_DIR) {
415 return process.env.NODE_CONFIG_DIR 416 return process.env.NODE_CONFIG_DIR
416 } 417 }
@@ -419,15 +420,17 @@ export function reloadConfig () {
419 } 420 }
420 421
421 function purge () { 422 function purge () {
423 const directory = getConfigDirectory()
424
422 for (const fileName in require.cache) { 425 for (const fileName in require.cache) {
423 if (fileName.includes(directory()) === false) { 426 if (fileName.includes(directory) === false) {
424 continue 427 continue
425 } 428 }
426 429
427 delete require.cache[fileName] 430 delete require.cache[fileName]
428 } 431 }
429 432
430 delete require.cache[require.resolve('config')] 433 decache('config')
431 } 434 }
432 435
433 purge() 436 purge()
diff --git a/server/lib/plugins/plugin-manager.ts b/server/lib/plugins/plugin-manager.ts
index 0086a0e2e..e3226a950 100644
--- a/server/lib/plugins/plugin-manager.ts
+++ b/server/lib/plugins/plugin-manager.ts
@@ -1,3 +1,4 @@
1import decache from 'decache'
1import * as express from 'express' 2import * as express from 'express'
2import { createReadStream, createWriteStream } from 'fs' 3import { createReadStream, createWriteStream } from 'fs'
3import { outputFile, readJSON } from 'fs-extra' 4import { outputFile, readJSON } from 'fs-extra'
@@ -23,8 +24,6 @@ import { ClientHtml } from '../client-html'
23import { RegisterHelpers } from './register-helpers' 24import { RegisterHelpers } from './register-helpers'
24import { installNpmPlugin, installNpmPluginFromDisk, removeNpmPlugin } from './yarn' 25import { installNpmPlugin, installNpmPluginFromDisk, removeNpmPlugin } from './yarn'
25 26
26const decache = require('decache')
27
28export interface RegisteredPlugin { 27export interface RegisteredPlugin {
29 npmName: string 28 npmName: string
30 name: string 29 name: string
diff --git a/yarn.lock b/yarn.lock
index 77710cfd3..5ba2b00b3 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -1845,7 +1845,7 @@ call-me-maybe@^1.0.1:
1845 resolved "https://registry.yarnpkg.com/call-me-maybe/-/call-me-maybe-1.0.1.tgz#26d208ea89e37b5cbde60250a15f031c16a4d66b" 1845 resolved "https://registry.yarnpkg.com/call-me-maybe/-/call-me-maybe-1.0.1.tgz#26d208ea89e37b5cbde60250a15f031c16a4d66b"
1846 integrity sha1-JtII6onje1y95gJQoV8DHBak1ms= 1846 integrity sha1-JtII6onje1y95gJQoV8DHBak1ms=
1847 1847
1848callsite@1.0.0: 1848callsite@1.0.0, callsite@^1.0.0:
1849 version "1.0.0" 1849 version "1.0.0"
1850 resolved "https://registry.yarnpkg.com/callsite/-/callsite-1.0.0.tgz#280398e5d664bd74038b6f0905153e6e8af1bc20" 1850 resolved "https://registry.yarnpkg.com/callsite/-/callsite-1.0.0.tgz#280398e5d664bd74038b6f0905153e6e8af1bc20"
1851 integrity sha1-KAOY5dZkvXQDi28JBRU+borxvCA= 1851 integrity sha1-KAOY5dZkvXQDi28JBRU+borxvCA=
@@ -2612,6 +2612,13 @@ debuglog@^1.0.0:
2612 resolved "https://registry.yarnpkg.com/debuglog/-/debuglog-1.0.1.tgz#aa24ffb9ac3df9a2351837cfb2d279360cd78492" 2612 resolved "https://registry.yarnpkg.com/debuglog/-/debuglog-1.0.1.tgz#aa24ffb9ac3df9a2351837cfb2d279360cd78492"
2613 integrity sha1-qiT/uaw9+aI1GDfPstJ5NgzXhJI= 2613 integrity sha1-qiT/uaw9+aI1GDfPstJ5NgzXhJI=
2614 2614
2615decache@^4.6.0:
2616 version "4.6.0"
2617 resolved "https://registry.yarnpkg.com/decache/-/decache-4.6.0.tgz#87026bc6e696759e82d57a3841c4e251a30356e8"
2618 integrity sha512-PppOuLiz+DFeaUvFXEYZjLxAkKiMYH/do/b/MxpDe/8AgKBi5GhZxridoVIbBq72GDbL36e4p0Ce2jTGUwwU+w==
2619 dependencies:
2620 callsite "^1.0.0"
2621
2615decamelize-keys@^1.0.0: 2622decamelize-keys@^1.0.0:
2616 version "1.1.0" 2623 version "1.1.0"
2617 resolved "https://registry.yarnpkg.com/decamelize-keys/-/decamelize-keys-1.1.0.tgz#d171a87933252807eb3cb61dc1c1445d078df2d9" 2624 resolved "https://registry.yarnpkg.com/decamelize-keys/-/decamelize-keys-1.1.0.tgz#d171a87933252807eb3cb61dc1c1445d078df2d9"