aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/initializers/checker.ts
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-10-25 16:03:33 +0200
committerChocobozzz <florian.bigard@gmail.com>2017-10-26 09:11:38 +0200
commitf5028693a896a3076dd286ac0030e3d8f78f5ebf (patch)
tree09144ed6357e49ea575fb110247f933283ad235e /server/initializers/checker.ts
parenteb08047657e739bcd9e592d76307befa3998482b (diff)
downloadPeerTube-f5028693a896a3076dd286ac0030e3d8f78f5ebf.tar.gz
PeerTube-f5028693a896a3076dd286ac0030e3d8f78f5ebf.tar.zst
PeerTube-f5028693a896a3076dd286ac0030e3d8f78f5ebf.zip
Use async/await in lib and initializers
Diffstat (limited to 'server/initializers/checker.ts')
-rw-r--r--server/initializers/checker.ts46
1 files changed, 22 insertions, 24 deletions
diff --git a/server/initializers/checker.ts b/server/initializers/checker.ts
index eb9e9e280..9eaef1695 100644
--- a/server/initializers/checker.ts
+++ b/server/initializers/checker.ts
@@ -37,39 +37,37 @@ function checkMissedConfig () {
37 37
38// Check the available codecs 38// Check the available codecs
39// We get CONFIG by param to not import it in this file (import orders) 39// We get CONFIG by param to not import it in this file (import orders)
40function checkFFmpeg (CONFIG: { TRANSCODING: { ENABLED: boolean } }) { 40async function checkFFmpeg (CONFIG: { TRANSCODING: { ENABLED: boolean } }) {
41 const Ffmpeg = require('fluent-ffmpeg') 41 const Ffmpeg = require('fluent-ffmpeg')
42 const getAvailableCodecsPromise = promisify0(Ffmpeg.getAvailableCodecs) 42 const getAvailableCodecsPromise = promisify0(Ffmpeg.getAvailableCodecs)
43 43
44 getAvailableCodecsPromise() 44 const codecs = await getAvailableCodecsPromise()
45 .then(codecs => { 45 if (CONFIG.TRANSCODING.ENABLED === false) return undefined
46 if (CONFIG.TRANSCODING.ENABLED === false) return undefined 46
47 47 const canEncode = [ 'libx264' ]
48 const canEncode = [ 'libx264' ] 48 for (const codec of canEncode) {
49 canEncode.forEach(codec => { 49 if (codecs[codec] === undefined) {
50 if (codecs[codec] === undefined) { 50 throw new Error('Unknown codec ' + codec + ' in FFmpeg.')
51 throw new Error('Unknown codec ' + codec + ' in FFmpeg.') 51 }
52 } 52
53 53 if (codecs[codec].canEncode !== true) {
54 if (codecs[codec].canEncode !== true) { 54 throw new Error('Unavailable encode codec ' + codec + ' in FFmpeg')
55 throw new Error('Unavailable encode codec ' + codec + ' in FFmpeg') 55 }
56 } 56 }
57 })
58 })
59} 57}
60 58
61// We get db by param to not import it in this file (import orders) 59// We get db by param to not import it in this file (import orders)
62function clientsExist (OAuthClient: OAuthClientModel) { 60async function clientsExist (OAuthClient: OAuthClientModel) {
63 return OAuthClient.countTotal().then(totalClients => { 61 const totalClients = await OAuthClient.countTotal()
64 return totalClients !== 0 62
65 }) 63 return totalClients !== 0
66} 64}
67 65
68// We get db by param to not import it in this file (import orders) 66// We get db by param to not import it in this file (import orders)
69function usersExist (User: UserModel) { 67async function usersExist (User: UserModel) {
70 return User.countTotal().then(totalUsers => { 68 const totalUsers = await User.countTotal()
71 return totalUsers !== 0 69
72 }) 70 return totalUsers !== 0
73} 71}
74 72
75// --------------------------------------------------------------------------- 73// ---------------------------------------------------------------------------