diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-01-12 15:20:03 +0100 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-01-12 15:20:03 +0100 |
commit | 99fe265a5fc077cb66c322e7f3d191ff7110aea0 (patch) | |
tree | c9e04ccfcc5496d2300d7c26db5833e494b4cdad /scripts/update-host.js | |
parent | fcc5f77b95d330bfcb439c172b7fcc58f3162e4d (diff) | |
parent | 91cc839af88730ba55f84997c56b85ea100070a7 (diff) | |
download | PeerTube-99fe265a5fc077cb66c322e7f3d191ff7110aea0.tar.gz PeerTube-99fe265a5fc077cb66c322e7f3d191ff7110aea0.tar.zst PeerTube-99fe265a5fc077cb66c322e7f3d191ff7110aea0.zip |
Merge branch 'postgresql'
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) { |