aboutsummaryrefslogtreecommitdiffhomepage
path: root/scripts/update-host.js
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/update-host.js')
-rwxr-xr-xscripts/update-host.js25
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
7const fs = require('fs') 7const fs = require('fs')
8const mongoose = require('mongoose')
9const parseTorrent = require('parse-torrent') 8const parseTorrent = require('parse-torrent')
10 9
11const constants = require('../server/initializers/constants') 10const constants = require('../server/initializers/constants')
12const database = require('../server/initializers/database') 11const db = require('../server/initializers/database')
13
14database.connect()
15 12
16const friends = require('../server/lib/friends') 13const friends = require('../server/lib/friends')
17const Video = mongoose.model('Video')
18
19friends.hasFriends(function (err, hasFriends) {
20 if (err) throw err
21 14
22 if (hasFriends === true) { 15db.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) {