From dd6019932efd6ae3b790bf024bc0cd74162e4517 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Sun, 25 Dec 2016 09:44:13 +0100 Subject: Update scripts with postgresql --- scripts/update-host.js | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) (limited to 'scripts/update-host.js') 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 @@ // TODO: document this script const fs = require('fs') -const mongoose = require('mongoose') const parseTorrent = require('parse-torrent') const constants = require('../server/initializers/constants') -const database = require('../server/initializers/database') - -database.connect() +const db = require('../server/initializers/database') const friends = require('../server/lib/friends') -const Video = mongoose.model('Video') - -friends.hasFriends(function (err, hasFriends) { - if (err) throw err - if (hasFriends === true) { - console.log('Cannot update host because you have friends!') - process.exit(-1) - } - - console.log('Updating videos host in database.') - Video.update({ }, { podHost: constants.CONFIG.WEBSERVER.HOST }, { multi: true }, function (err) { +db.init(true, function () { + friends.hasFriends(function (err, hasFriends) { if (err) throw err + if (hasFriends === true) { + console.log('Cannot update host because you have friends!') + process.exit(-1) + } + console.log('Updating torrent files.') - Video.find().lean().exec(function (err, videos) { + db.Video.list(function (err, videos) { if (err) throw err videos.forEach(function (video) { -- cgit v1.2.3