diff options
Diffstat (limited to 'scripts/update-host.js')
-rwxr-xr-x | scripts/update-host.js | 25 |
1 files changed, 9 insertions, 16 deletions
diff --git a/scripts/update-host.js b/scripts/update-host.js index 8a17f2402..91051e68b 100755 --- a/scripts/update-host.js +++ b/scripts/update-host.js | |||
@@ -5,31 +5,24 @@ | |||
5 | // TODO: document this script | 5 | // TODO: document this script |
6 | 6 | ||
7 | const fs = require('fs') | 7 | const fs = require('fs') |
8 | const mongoose = require('mongoose') | ||
9 | const parseTorrent = require('parse-torrent') | 8 | const parseTorrent = require('parse-torrent') |
10 | 9 | ||
11 | const constants = require('../server/initializers/constants') | 10 | const constants = require('../server/initializers/constants') |
12 | const database = require('../server/initializers/database') | 11 | const db = require('../server/initializers/database') |
13 | |||
14 | database.connect() | ||
15 | 12 | ||
16 | const friends = require('../server/lib/friends') | 13 | const friends = require('../server/lib/friends') |
17 | const Video = mongoose.model('Video') | ||
18 | |||
19 | friends.hasFriends(function (err, hasFriends) { | ||
20 | if (err) throw err | ||
21 | 14 | ||
22 | if (hasFriends === true) { | 15 | db.init(true, function () { |
23 | console.log('Cannot update host because you have friends!') | 16 | friends.hasFriends(function (err, hasFriends) { |
24 | process.exit(-1) | ||
25 | } | ||
26 | |||
27 | console.log('Updating videos host in database.') | ||
28 | Video.update({ }, { podHost: constants.CONFIG.WEBSERVER.HOST }, { multi: true }, function (err) { | ||
29 | if (err) throw err | 17 | if (err) throw err |
30 | 18 | ||
19 | if (hasFriends === true) { | ||
20 | console.log('Cannot update host because you have friends!') | ||
21 | process.exit(-1) | ||
22 | } | ||
23 | |||
31 | console.log('Updating torrent files.') | 24 | console.log('Updating torrent files.') |
32 | Video.find().lean().exec(function (err, videos) { | 25 | db.Video.list(function (err, videos) { |
33 | if (err) throw err | 26 | if (err) throw err |
34 | 27 | ||
35 | videos.forEach(function (video) { | 28 | videos.forEach(function (video) { |