aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-03-19 16:33:40 +0100
committerChocobozzz <me@florianbigard.com>2019-03-19 16:33:40 +0100
commitd85798c4e7b18f3b464fa819ffc5bec06137e3e9 (patch)
tree56fe546d0d237676c3f9b462bba12156e5d82225
parent2ba92871319d7af63472c1380664a9f9eeb1c690 (diff)
downloadPeerTube-d85798c4e7b18f3b464fa819ffc5bec06137e3e9.tar.gz
PeerTube-d85798c4e7b18f3b464fa819ffc5bec06137e3e9.tar.zst
PeerTube-d85798c4e7b18f3b464fa819ffc5bec06137e3e9.zip
Better videos redundancy config error handling
-rw-r--r--server/initializers/checker-after-init.ts3
-rw-r--r--server/initializers/checker-before-init.ts4
-rw-r--r--server/initializers/constants.ts2
3 files changed, 7 insertions, 2 deletions
diff --git a/server/initializers/checker-after-init.ts b/server/initializers/checker-after-init.ts
index 53124f9ec..a99dbba37 100644
--- a/server/initializers/checker-after-init.ts
+++ b/server/initializers/checker-after-init.ts
@@ -61,6 +61,7 @@ function checkConfig () {
61 61
62 // Redundancies 62 // Redundancies
63 const redundancyVideos = CONFIG.REDUNDANCY.VIDEOS.STRATEGIES 63 const redundancyVideos = CONFIG.REDUNDANCY.VIDEOS.STRATEGIES
64 console.log(redundancyVideos)
64 if (isArray(redundancyVideos)) { 65 if (isArray(redundancyVideos)) {
65 const available = [ 'most-views', 'trending', 'recently-added' ] 66 const available = [ 'most-views', 'trending', 'recently-added' ]
66 for (const r of redundancyVideos) { 67 for (const r of redundancyVideos) {
@@ -83,6 +84,8 @@ function checkConfig () {
83 if (recentlyAddedStrategy && isNaN(recentlyAddedStrategy.minViews)) { 84 if (recentlyAddedStrategy && isNaN(recentlyAddedStrategy.minViews)) {
84 return 'Min views in recently added strategy is not a number' 85 return 'Min views in recently added strategy is not a number'
85 } 86 }
87 } else {
88 return 'Videos redundancy should be an array (you must uncomment lines containing - too)'
86 } 89 }
87 90
88 // Check storage directory locations 91 // Check storage directory locations
diff --git a/server/initializers/checker-before-init.ts b/server/initializers/checker-before-init.ts
index 3e1d2c589..ef12b3eea 100644
--- a/server/initializers/checker-before-init.ts
+++ b/server/initializers/checker-before-init.ts
@@ -1,6 +1,5 @@
1import * as config from 'config' 1import * as config from 'config'
2import { promisify0 } from '../helpers/core-utils' 2import { promisify0 } from '../helpers/core-utils'
3import { isArray } from '../helpers/custom-validators/misc'
4 3
5// ONLY USE CORE MODULES IN THIS FILE! 4// ONLY USE CORE MODULES IN THIS FILE!
6 5
@@ -42,7 +41,8 @@ function checkMissedConfig () {
42 } 41 }
43 42
44 const redundancyVideos = config.get<any>('redundancy.videos.strategies') 43 const redundancyVideos = config.get<any>('redundancy.videos.strategies')
45 if (isArray(redundancyVideos)) { 44
45 if (Array.isArray(redundancyVideos)) {
46 for (const r of redundancyVideos) { 46 for (const r of redundancyVideos) {
47 if (!r.size) miss.push('redundancy.videos.strategies.size') 47 if (!r.size) miss.push('redundancy.videos.strategies.size')
48 if (!r.min_lifetime) miss.push('redundancy.videos.strategies.min_lifetime') 48 if (!r.min_lifetime) miss.push('redundancy.videos.strategies.min_lifetime')
diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts
index 7a3ec3874..54cd57619 100644
--- a/server/initializers/constants.ts
+++ b/server/initializers/constants.ts
@@ -881,6 +881,8 @@ function buildVideosExtname () {
881function buildVideosRedundancy (objs: any[]): VideosRedundancy[] { 881function buildVideosRedundancy (objs: any[]): VideosRedundancy[] {
882 if (!objs) return [] 882 if (!objs) return []
883 883
884 if (!Array.isArray(objs)) return objs
885
884 return objs.map(obj => { 886 return objs.map(obj => {
885 return Object.assign({}, obj, { 887 return Object.assign({}, obj, {
886 minLifetime: parseDuration(obj.min_lifetime), 888 minLifetime: parseDuration(obj.min_lifetime),