X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Finitializers%2Fchecker.ts;h=9eaef16952978424094381a0f8442caf8648d25d;hb=f5028693a896a3076dd286ac0030e3d8f78f5ebf;hp=97606ef311068b7156c0b486d00d94f327eb98bc;hpb=3482688cce11495b51970f680f375ed56deb4464;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/initializers/checker.ts b/server/initializers/checker.ts index 97606ef31..9eaef1695 100644 --- a/server/initializers/checker.ts +++ b/server/initializers/checker.ts @@ -22,7 +22,7 @@ function checkMissedConfig () { 'webserver.https', 'webserver.hostname', 'webserver.port', 'database.hostname', 'database.port', 'database.suffix', 'database.username', 'database.password', 'storage.certs', 'storage.videos', 'storage.logs', 'storage.thumbnails', 'storage.previews', 'storage.torrents', 'storage.cache', - 'cache.previews.size', 'admin.email', 'signup.enabled', 'signup.limit', 'transcoding.enabled', 'transcoding.threads' + 'cache.previews.size', 'admin.email', 'signup.enabled', 'signup.limit', 'transcoding.enabled', 'transcoding.threads', 'user.video_quota' ] const miss: string[] = [] @@ -37,39 +37,37 @@ function checkMissedConfig () { // Check the available codecs // We get CONFIG by param to not import it in this file (import orders) -function checkFFmpeg (CONFIG: { TRANSCODING: { ENABLED: boolean } }) { +async function checkFFmpeg (CONFIG: { TRANSCODING: { ENABLED: boolean } }) { const Ffmpeg = require('fluent-ffmpeg') const getAvailableCodecsPromise = promisify0(Ffmpeg.getAvailableCodecs) - getAvailableCodecsPromise() - .then(codecs => { - if (CONFIG.TRANSCODING.ENABLED === false) return undefined - - const canEncode = [ 'libx264' ] - canEncode.forEach(codec => { - if (codecs[codec] === undefined) { - throw new Error('Unknown codec ' + codec + ' in FFmpeg.') - } - - if (codecs[codec].canEncode !== true) { - throw new Error('Unavailable encode codec ' + codec + ' in FFmpeg') - } - }) - }) + const codecs = await getAvailableCodecsPromise() + if (CONFIG.TRANSCODING.ENABLED === false) return undefined + + const canEncode = [ 'libx264' ] + for (const codec of canEncode) { + if (codecs[codec] === undefined) { + throw new Error('Unknown codec ' + codec + ' in FFmpeg.') + } + + if (codecs[codec].canEncode !== true) { + throw new Error('Unavailable encode codec ' + codec + ' in FFmpeg') + } + } } // We get db by param to not import it in this file (import orders) -function clientsExist (OAuthClient: OAuthClientModel) { - return OAuthClient.countTotal().then(totalClients => { - return totalClients !== 0 - }) +async function clientsExist (OAuthClient: OAuthClientModel) { + const totalClients = await OAuthClient.countTotal() + + return totalClients !== 0 } // We get db by param to not import it in this file (import orders) -function usersExist (User: UserModel) { - return User.countTotal().then(totalUsers => { - return totalUsers !== 0 - }) +async function usersExist (User: UserModel) { + const totalUsers = await User.countTotal() + + return totalUsers !== 0 } // ---------------------------------------------------------------------------