Better videos redundancy config error handling
This commit is contained in:
parent
2ba9287131
commit
d85798c4e7
|
@ -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
|
||||
|
|
|
@ -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')
|
||||
|
|
|
@ -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),
|
||||
|
|
Loading…
Reference in New Issue