diff options
Diffstat (limited to 'server/lib/requestsScheduler.js')
-rw-r--r-- | server/lib/requestsScheduler.js | 18 |
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 | ||
3 | const async = require('async') | 3 | const async = require('async') |
4 | const map = require('lodash/map') | 4 | const map = require('lodash/map') |
5 | const mongoose = require('mongoose') | ||
5 | 6 | ||
6 | const constants = require('../initializers/constants') | 7 | const constants = require('../initializers/constants') |
7 | const logger = require('../helpers/logger') | 8 | const logger = require('../helpers/logger') |
8 | const Pods = require('../models/pods') | 9 | const Pods = require('../models/pods') |
9 | const Requests = require('../models/requests') | 10 | const Requests = require('../models/requests') |
10 | const requests = require('../helpers/requests') | 11 | const requests = require('../helpers/requests') |
11 | const videos = require('../lib/videos') | 12 | |
12 | const Videos = require('../models/videos') | 13 | const Video = mongoose.model('Video') |
13 | 14 | ||
14 | let timer = null | 15 | let 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 | }) |