aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/requestsScheduler.js
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2016-05-10 21:19:24 +0200
committerChocobozzz <florian.bigard@gmail.com>2016-05-10 21:19:24 +0200
commitcbe2f7c34822b1bd3b1f8c691f79f0c29cf21f07 (patch)
treece678124210db8b03b2a523e3b92a14cc403eeee /server/lib/requestsScheduler.js
parentf1dae018681936b556b2496b7f2d872c004cfda3 (diff)
downloadPeerTube-cbe2f7c34822b1bd3b1f8c691f79f0c29cf21f07.tar.gz
PeerTube-cbe2f7c34822b1bd3b1f8c691f79f0c29cf21f07.tar.zst
PeerTube-cbe2f7c34822b1bd3b1f8c691f79f0c29cf21f07.zip
Refractoring and add thumbnails support (without tests)
Diffstat (limited to 'server/lib/requestsScheduler.js')
-rw-r--r--server/lib/requestsScheduler.js12
1 files changed, 7 insertions, 5 deletions
diff --git a/server/lib/requestsScheduler.js b/server/lib/requestsScheduler.js
index 2c5474e51..4953f6a91 100644
--- a/server/lib/requestsScheduler.js
+++ b/server/lib/requestsScheduler.js
@@ -8,6 +8,7 @@ const logger = require('../helpers/logger')
8const Pods = require('../models/pods') 8const Pods = require('../models/pods')
9const Requests = require('../models/requests') 9const Requests = require('../models/requests')
10const requests = require('../helpers/requests') 10const requests = require('../helpers/requests')
11const videos = require('../lib/videos')
11const Videos = require('../models/videos') 12const Videos = require('../models/videos')
12 13
13let timer = null 14let timer = null
@@ -99,7 +100,7 @@ function makeRequest (type, requests_to_make, callback) {
99 requests.makeMultipleRetryRequest(params, pods, callbackEachPodFinished, callbackAllPodsFinished) 100 requests.makeMultipleRetryRequest(params, pods, callbackEachPodFinished, callbackAllPodsFinished)
100 101
101 function callbackEachPodFinished (err, response, body, url, pod, callback_each_pod_finished) { 102 function callbackEachPodFinished (err, response, body, url, pod, callback_each_pod_finished) {
102 if (err || (response.statusCode !== 200 && response.statusCode !== 204)) { 103 if (err || (response.statusCode !== 200 && response.statusCode !== 201 && response.statusCode !== 204)) {
103 bad_pods.push(pod._id) 104 bad_pods.push(pod._id)
104 logger.error('Error sending secure request to %s pod.', url, { error: err || new Error('Status code not 20x') }) 105 logger.error('Error sending secure request to %s pod.', url, { error: err || new Error('Status code not 20x') })
105 } else { 106 } else {
@@ -187,12 +188,13 @@ function removeBadPods () {
187 const urls = map(pods, 'url') 188 const urls = map(pods, 'url')
188 const ids = map(pods, '_id') 189 const ids = map(pods, '_id')
189 190
190 Videos.removeAllRemotesOf(urls, function (err, r) { 191 Videos.listFromUrls(urls, function (err, videos_list) {
191 if (err) { 192 if (err) {
192 logger.error('Cannot remove videos from a pod that we removing.', { error: err }) 193 logger.error('Cannot list videos urls.', { error: err, urls: urls })
193 } else { 194 } else {
194 const videos_removed = r.result.n 195 videos.removeRemoteVideos(videos_list, function (err) {
195 logger.info('Removed %d videos.', videos_removed) 196 if (err) logger.error('Cannot remove remote videos.', { error: err })
197 })
196 } 198 }
197 199
198 Pods.removeAllByIds(ids, function (err, r) { 200 Pods.removeAllByIds(ids, function (err, r) {