Better videos redundancy config error handling

This commit is contained in:
Chocobozzz 2019-03-19 16:33:40 +01:00
parent 2ba9287131
commit d85798c4e7
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
3 changed files with 7 additions and 2 deletions

View File

@ -61,6 +61,7 @@ function checkConfig () {
// Redundancies
const redundancyVideos = CONFIG.REDUNDANCY.VIDEOS.STRATEGIES
console.log(redundancyVideos)
if (isArray(redundancyVideos)) {
const available = [ 'most-views', 'trending', 'recently-added' ]
for (const r of redundancyVideos) {
@ -83,6 +84,8 @@ function checkConfig () {
if (recentlyAddedStrategy && isNaN(recentlyAddedStrategy.minViews)) {
return 'Min views in recently added strategy is not a number'
}
} else {
return 'Videos redundancy should be an array (you must uncomment lines containing - too)'
}
// Check storage directory locations

View File

@ -1,6 +1,5 @@
import * as config from 'config'
import { promisify0 } from '../helpers/core-utils'
import { isArray } from '../helpers/custom-validators/misc'
// ONLY USE CORE MODULES IN THIS FILE!
@ -42,7 +41,8 @@ function checkMissedConfig () {
}
const redundancyVideos = config.get<any>('redundancy.videos.strategies')
if (isArray(redundancyVideos)) {
if (Array.isArray(redundancyVideos)) {
for (const r of redundancyVideos) {
if (!r.size) miss.push('redundancy.videos.strategies.size')
if (!r.min_lifetime) miss.push('redundancy.videos.strategies.min_lifetime')

View File

@ -881,6 +881,8 @@ function buildVideosExtname () {
function buildVideosRedundancy (objs: any[]): VideosRedundancy[] {
if (!objs) return []
if (!Array.isArray(objs)) return objs
return objs.map(obj => {
return Object.assign({}, obj, {
minLifetime: parseDuration(obj.min_lifetime),