diff options
Diffstat (limited to 'server/initializers/installer.ts')
-rw-r--r-- | server/initializers/installer.ts | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/server/initializers/installer.ts b/server/initializers/installer.ts index b9a9da183..127449577 100644 --- a/server/initializers/installer.ts +++ b/server/initializers/installer.ts | |||
@@ -1,14 +1,15 @@ | |||
1 | import * as passwordGenerator from 'password-generator' | 1 | import * as passwordGenerator from 'password-generator' |
2 | import { UserRole } from '../../shared' | 2 | import { UserRole } from '../../shared' |
3 | import { logger } from '../helpers/logger' | 3 | import { logger } from '../helpers/logger' |
4 | import { createApplicationActor, createUserAccountAndChannel } from '../lib/user' | 4 | import { createApplicationActor, createUserAccountAndChannelAndPlaylist } from '../lib/user' |
5 | import { UserModel } from '../models/account/user' | 5 | import { UserModel } from '../models/account/user' |
6 | import { ApplicationModel } from '../models/application/application' | 6 | import { ApplicationModel } from '../models/application/application' |
7 | import { OAuthClientModel } from '../models/oauth/oauth-client' | 7 | import { OAuthClientModel } from '../models/oauth/oauth-client' |
8 | import { applicationExist, clientsExist, usersExist } from './checker-after-init' | 8 | import { applicationExist, clientsExist, usersExist } from './checker-after-init' |
9 | import { CACHE, CONFIG, LAST_MIGRATION_VERSION } from './constants' | 9 | import { FILES_CACHE, HLS_STREAMING_PLAYLIST_DIRECTORY, LAST_MIGRATION_VERSION } from './constants' |
10 | import { sequelizeTypescript } from './database' | 10 | import { sequelizeTypescript } from './database' |
11 | import { remove, ensureDir } from 'fs-extra' | 11 | import { ensureDir, remove } from 'fs-extra' |
12 | import { CONFIG } from './config' | ||
12 | 13 | ||
13 | async function installApplication () { | 14 | async function installApplication () { |
14 | try { | 15 | try { |
@@ -24,7 +25,7 @@ async function installApplication () { | |||
24 | }), | 25 | }), |
25 | 26 | ||
26 | // Directories | 27 | // Directories |
27 | removeCacheDirectories() | 28 | removeCacheAndTmpDirectories() |
28 | .then(() => createDirectoriesIfNotExist()) | 29 | .then(() => createDirectoriesIfNotExist()) |
29 | ]) | 30 | ]) |
30 | } catch (err) { | 31 | } catch (err) { |
@@ -41,9 +42,9 @@ export { | |||
41 | 42 | ||
42 | // --------------------------------------------------------------------------- | 43 | // --------------------------------------------------------------------------- |
43 | 44 | ||
44 | function removeCacheDirectories () { | 45 | function removeCacheAndTmpDirectories () { |
45 | const cacheDirectories = Object.keys(CACHE) | 46 | const cacheDirectories = Object.keys(FILES_CACHE) |
46 | .map(k => CACHE[k].DIRECTORY) | 47 | .map(k => FILES_CACHE[k].DIRECTORY) |
47 | 48 | ||
48 | const tasks: Promise<any>[] = [] | 49 | const tasks: Promise<any>[] = [] |
49 | 50 | ||
@@ -53,13 +54,15 @@ function removeCacheDirectories () { | |||
53 | tasks.push(remove(dir)) | 54 | tasks.push(remove(dir)) |
54 | } | 55 | } |
55 | 56 | ||
57 | tasks.push(remove(CONFIG.STORAGE.TMP_DIR)) | ||
58 | |||
56 | return Promise.all(tasks) | 59 | return Promise.all(tasks) |
57 | } | 60 | } |
58 | 61 | ||
59 | function createDirectoriesIfNotExist () { | 62 | function createDirectoriesIfNotExist () { |
60 | const storage = CONFIG.STORAGE | 63 | const storage = CONFIG.STORAGE |
61 | const cacheDirectories = Object.keys(CACHE) | 64 | const cacheDirectories = Object.keys(FILES_CACHE) |
62 | .map(k => CACHE[k].DIRECTORY) | 65 | .map(k => FILES_CACHE[k].DIRECTORY) |
63 | 66 | ||
64 | const tasks: Promise<void>[] = [] | 67 | const tasks: Promise<void>[] = [] |
65 | for (const key of Object.keys(storage)) { | 68 | for (const key of Object.keys(storage)) { |
@@ -73,6 +76,9 @@ function createDirectoriesIfNotExist () { | |||
73 | tasks.push(ensureDir(dir)) | 76 | tasks.push(ensureDir(dir)) |
74 | } | 77 | } |
75 | 78 | ||
79 | // Playlist directories | ||
80 | tasks.push(ensureDir(HLS_STREAMING_PLAYLIST_DIRECTORY)) | ||
81 | |||
76 | return Promise.all(tasks) | 82 | return Promise.all(tasks) |
77 | } | 83 | } |
78 | 84 | ||
@@ -138,7 +144,7 @@ async function createOAuthAdminIfNotExist () { | |||
138 | } | 144 | } |
139 | const user = new UserModel(userData) | 145 | const user = new UserModel(userData) |
140 | 146 | ||
141 | await createUserAccountAndChannel(user, validatePassword) | 147 | await createUserAccountAndChannelAndPlaylist(user, validatePassword) |
142 | logger.info('Username: ' + username) | 148 | logger.info('Username: ' + username) |
143 | logger.info('User password: ' + password) | 149 | logger.info('User password: ' + password) |
144 | } | 150 | } |