]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/initializers/installer.ts
Improve video edit/update/add typings
[github/Chocobozzz/PeerTube.git] / server / initializers / installer.ts
index 58713c2c415da6aa81044d1b9a4f474fd5f40950..1f513a9c37354f312537ca625dd7c4e03cebf4e6 100644 (file)
@@ -19,8 +19,8 @@ async function installApplication () {
     await createOAuthClientIfNotExist()
     await createOAuthAdminIfNotExist()
   } catch (err) {
-    logger.error('Cannot install application.', err)
-    throw err
+    logger.error('Cannot install application.', { err })
+    process.exit(-1)
   }
 }
 
@@ -33,7 +33,8 @@ export {
 // ---------------------------------------------------------------------------
 
 function removeCacheDirectories () {
-  const cacheDirectories = CACHE.DIRECTORIES
+  const cacheDirectories = Object.keys(CACHE)
+    .map(k => CACHE[k].DIRECTORY)
 
   const tasks: Promise<any>[] = []
 
@@ -48,7 +49,8 @@ function removeCacheDirectories () {
 
 function createDirectoriesIfNotExist () {
   const storage = CONFIG.STORAGE
-  const cacheDirectories = CACHE.DIRECTORIES
+  const cacheDirectories = Object.keys(CACHE)
+                                 .map(k => CACHE[k].DIRECTORY)
 
   const tasks = []
   for (const key of Object.keys(storage)) {
@@ -112,7 +114,7 @@ async function createOAuthAdminIfNotExist () {
     // Our password is weak so do not validate it
     validatePassword = false
   } else {
-    password = passwordGenerator(8, true)
+    password = passwordGenerator(16, true)
   }
 
   const userData = {
@@ -120,6 +122,7 @@ async function createOAuthAdminIfNotExist () {
     email,
     password,
     role,
+    nsfwPolicy: CONFIG.INSTANCE.DEFAULT_NSFW_POLICY,
     videoQuota: -1
   }
   const user = new UserModel(userData)
@@ -134,8 +137,6 @@ async function createApplicationIfNotExist () {
   // Nothing to do, application already exist
   if (exist === true) return undefined
 
-  logger.info('Creating Application table.')
-
   logger.info('Creating application account.')
 
   const application = await ApplicationModel.create({