aboutsummaryrefslogtreecommitdiffhomepage
path: root/scripts/update-host.js
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-01-12 15:20:03 +0100
committerChocobozzz <florian.bigard@gmail.com>2017-01-12 15:20:03 +0100
commit99fe265a5fc077cb66c322e7f3d191ff7110aea0 (patch)
treec9e04ccfcc5496d2300d7c26db5833e494b4cdad /scripts/update-host.js
parentfcc5f77b95d330bfcb439c172b7fcc58f3162e4d (diff)
parent91cc839af88730ba55f84997c56b85ea100070a7 (diff)
downloadPeerTube-99fe265a5fc077cb66c322e7f3d191ff7110aea0.tar.gz
PeerTube-99fe265a5fc077cb66c322e7f3d191ff7110aea0.tar.zst
PeerTube-99fe265a5fc077cb66c322e7f3d191ff7110aea0.zip
Merge branch 'postgresql'
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) {