aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/requestsScheduler.js
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib/requestsScheduler.js')
-rw-r--r--server/lib/requestsScheduler.js18
1 files changed, 12 insertions, 6 deletions
diff --git a/server/lib/requestsScheduler.js b/server/lib/requestsScheduler.js
index ac75e5b93..b192d8299 100644
--- a/server/lib/requestsScheduler.js
+++ b/server/lib/requestsScheduler.js
@@ -2,14 +2,15 @@
2 2
3const async = require('async') 3const async = require('async')
4const map = require('lodash/map') 4const map = require('lodash/map')
5const mongoose = require('mongoose')
5 6
6const constants = require('../initializers/constants') 7const constants = require('../initializers/constants')
7const logger = require('../helpers/logger') 8const logger = require('../helpers/logger')
8const Pods = require('../models/pods') 9const Pods = require('../models/pods')
9const Requests = require('../models/requests') 10const Requests = require('../models/requests')
10const requests = require('../helpers/requests') 11const requests = require('../helpers/requests')
11const videos = require('../lib/videos') 12
12const Videos = require('../models/videos') 13const Video = mongoose.model('Video')
13 14
14let timer = null 15let timer = null
15 16
@@ -210,7 +211,7 @@ function removeBadPods () {
210 const urls = map(pods, 'url') 211 const urls = map(pods, 'url')
211 const ids = map(pods, '_id') 212 const ids = map(pods, '_id')
212 213
213 Videos.listFromUrls(urls, function (err, videosList) { 214 Video.listByUrls(urls, function (err, videosList) {
214 if (err) { 215 if (err) {
215 logger.error('Cannot list videos urls.', { error: err, urls: urls }) 216 logger.error('Cannot list videos urls.', { error: err, urls: urls })
216 return callback(null, ids, []) 217 return callback(null, ids, [])
@@ -224,9 +225,14 @@ function removeBadPods () {
224 // We don't have to remove pods, skip 225 // We don't have to remove pods, skip
225 if (typeof podIds === 'function') return podIds(null) 226 if (typeof podIds === 'function') return podIds(null)
226 227
227 // Remove the remote videos 228 async.each(videosList, function (video, callbackEach) {
228 videos.removeRemoteVideos(videosList, function (err) { 229 video.remove(callbackEach)
229 if (err) logger.error('Cannot remove remote videos.', { error: err }) 230 }, function (err) {
231 if (err) {
232 // Don't stop the process
233 logger.error('Error while removing videos of bad pods.', { error: err })
234 return
235 }
230 236
231 return callback(null, podIds) 237 return callback(null, podIds)
232 }) 238 })