aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/initializers/checker.js
diff options
context:
space:
mode:
Diffstat (limited to 'server/initializers/checker.js')
-rw-r--r--server/initializers/checker.js31
1 files changed, 17 insertions, 14 deletions
diff --git a/server/initializers/checker.js b/server/initializers/checker.js
index a21e54982..cb62fabf4 100644
--- a/server/initializers/checker.js
+++ b/server/initializers/checker.js
@@ -1,12 +1,13 @@
1'use strict' 1'use strict'
2 2
3const config = require('config') 3const config = require('config')
4const mkdirp = require('mkdirp') 4
5const path = require('path') 5const Users = require('../models/users')
6 6
7const checker = { 7const checker = {
8 checkConfig: checkConfig, 8 checkConfig: checkConfig,
9 createDirectoriesIfNotExist: createDirectoriesIfNotExist 9 clientsExist: clientsExist,
10 usersExist: usersExist
10} 11}
11 12
12// Check the config files 13// Check the config files
@@ -27,18 +28,20 @@ function checkConfig () {
27 return miss 28 return miss
28} 29}
29 30
30// Create directories for the storage if it doesn't exist 31function clientsExist (callback) {
31function createDirectoriesIfNotExist () { 32 Users.getClients(function (err, clients) {
32 const storages = config.get('storage') 33 if (err) return callback(err)
33 34
34 for (const key of Object.keys(storages)) { 35 return callback(null, clients.length !== 0)
35 const dir = storages[key] 36 })
36 try { 37}
37 mkdirp.sync(path.join(__dirname, '..', '..', dir)) 38
38 } catch (error) { 39function usersExist (callback) {
39 throw new Error('Cannot create ' + path + ':' + error) 40 Users.getUsers(function (err, users) {
40 } 41 if (err) return callback(err)
41 } 42
43 return callback(null, users.length !== 0)
44 })
42} 45}
43 46
44// --------------------------------------------------------------------------- 47// ---------------------------------------------------------------------------