aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-09-20 16:16:07 +0200
committerChocobozzz <me@florianbigard.com>2018-09-20 16:25:00 +0200
commit00f9e41ebfaed4867e971bfb8042e3359eb67eda (patch)
tree6c67c4c3295297ff89208ab7da265df53985d570 /server
parenta89368105879d2468a2d474367a68d5c1be99089 (diff)
downloadPeerTube-00f9e41ebfaed4867e971bfb8042e3359eb67eda.tar.gz
PeerTube-00f9e41ebfaed4867e971bfb8042e3359eb67eda.tar.zst
PeerTube-00f9e41ebfaed4867e971bfb8042e3359eb67eda.zip
Add warning if one of the storage directory is in the peertube
production directory Because admins could loose these directories on peertube upgrade
Diffstat (limited to 'server')
-rw-r--r--server/helpers/core-utils.ts6
-rw-r--r--server/initializers/checker.ts14
2 files changed, 19 insertions, 1 deletions
diff --git a/server/helpers/core-utils.ts b/server/helpers/core-utils.ts
index f5ef187fe..b1a27e089 100644
--- a/server/helpers/core-utils.ts
+++ b/server/helpers/core-utils.ts
@@ -64,6 +64,10 @@ function isTestInstance () {
64 return process.env.NODE_ENV === 'test' 64 return process.env.NODE_ENV === 'test'
65} 65}
66 66
67function isProdInstance () {
68 return process.env.NODE_ENV === 'production'
69}
70
67function root () { 71function root () {
68 // We are in /helpers/utils.js 72 // We are in /helpers/utils.js
69 const paths = [ __dirname, '..', '..' ] 73 const paths = [ __dirname, '..', '..' ]
@@ -179,6 +183,8 @@ const createTorrentPromise = promisify2<string, any, any>(createTorrent)
179 183
180export { 184export {
181 isTestInstance, 185 isTestInstance,
186 isProdInstance,
187
182 root, 188 root,
183 escapeHTML, 189 escapeHTML,
184 pageToStartAndCount, 190 pageToStartAndCount,
diff --git a/server/initializers/checker.ts b/server/initializers/checker.ts
index a54f6155b..5b068caa1 100644
--- a/server/initializers/checker.ts
+++ b/server/initializers/checker.ts
@@ -1,5 +1,5 @@
1import * as config from 'config' 1import * as config from 'config'
2import { promisify0 } from '../helpers/core-utils' 2import { promisify0, isProdInstance } from '../helpers/core-utils'
3import { UserModel } from '../models/account/user' 3import { UserModel } from '../models/account/user'
4import { ApplicationModel } from '../models/application/application' 4import { ApplicationModel } from '../models/application/application'
5import { OAuthClientModel } from '../models/oauth/oauth-client' 5import { OAuthClientModel } from '../models/oauth/oauth-client'
@@ -59,6 +59,18 @@ function checkConfig () {
59 } 59 }
60 } 60 }
61 61
62 if (isProdInstance()) {
63 const configStorage = config.get('storage')
64 for (const key of Object.keys(configStorage)) {
65 if (configStorage[key].startsWith('storage/')) {
66 logger.warn(
67 'Directory of %s should not be in the production directory of PeerTube. Please check your production configuration file.',
68 key
69 )
70 }
71 }
72 }
73
62 return null 74 return null
63} 75}
64 76