Better videos redundancy config error handling
This commit is contained in:
parent
2ba9287131
commit
d85798c4e7
3 changed files with 7 additions and 2 deletions
|
@ -61,6 +61,7 @@ function checkConfig () {
|
||||||
|
|
||||||
// Redundancies
|
// Redundancies
|
||||||
const redundancyVideos = CONFIG.REDUNDANCY.VIDEOS.STRATEGIES
|
const redundancyVideos = CONFIG.REDUNDANCY.VIDEOS.STRATEGIES
|
||||||
|
console.log(redundancyVideos)
|
||||||
if (isArray(redundancyVideos)) {
|
if (isArray(redundancyVideos)) {
|
||||||
const available = [ 'most-views', 'trending', 'recently-added' ]
|
const available = [ 'most-views', 'trending', 'recently-added' ]
|
||||||
for (const r of redundancyVideos) {
|
for (const r of redundancyVideos) {
|
||||||
|
@ -83,6 +84,8 @@ function checkConfig () {
|
||||||
if (recentlyAddedStrategy && isNaN(recentlyAddedStrategy.minViews)) {
|
if (recentlyAddedStrategy && isNaN(recentlyAddedStrategy.minViews)) {
|
||||||
return 'Min views in recently added strategy is not a number'
|
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
|
// Check storage directory locations
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import * as config from 'config'
|
import * as config from 'config'
|
||||||
import { promisify0 } from '../helpers/core-utils'
|
import { promisify0 } from '../helpers/core-utils'
|
||||||
import { isArray } from '../helpers/custom-validators/misc'
|
|
||||||
|
|
||||||
// ONLY USE CORE MODULES IN THIS FILE!
|
// ONLY USE CORE MODULES IN THIS FILE!
|
||||||
|
|
||||||
|
@ -42,7 +41,8 @@ function checkMissedConfig () {
|
||||||
}
|
}
|
||||||
|
|
||||||
const redundancyVideos = config.get<any>('redundancy.videos.strategies')
|
const redundancyVideos = config.get<any>('redundancy.videos.strategies')
|
||||||
if (isArray(redundancyVideos)) {
|
|
||||||
|
if (Array.isArray(redundancyVideos)) {
|
||||||
for (const r of redundancyVideos) {
|
for (const r of redundancyVideos) {
|
||||||
if (!r.size) miss.push('redundancy.videos.strategies.size')
|
if (!r.size) miss.push('redundancy.videos.strategies.size')
|
||||||
if (!r.min_lifetime) miss.push('redundancy.videos.strategies.min_lifetime')
|
if (!r.min_lifetime) miss.push('redundancy.videos.strategies.min_lifetime')
|
||||||
|
|
|
@ -881,6 +881,8 @@ function buildVideosExtname () {
|
||||||
function buildVideosRedundancy (objs: any[]): VideosRedundancy[] {
|
function buildVideosRedundancy (objs: any[]): VideosRedundancy[] {
|
||||||
if (!objs) return []
|
if (!objs) return []
|
||||||
|
|
||||||
|
if (!Array.isArray(objs)) return objs
|
||||||
|
|
||||||
return objs.map(obj => {
|
return objs.map(obj => {
|
||||||
return Object.assign({}, obj, {
|
return Object.assign({}, obj, {
|
||||||
minLifetime: parseDuration(obj.min_lifetime),
|
minLifetime: parseDuration(obj.min_lifetime),
|
||||||
|
|
Loading…
Add table
Reference in a new issue