diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2016-06-24 17:42:51 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2016-06-24 17:42:51 +0200 |
commit | aaf61f3810e6d57c5130af959bd2860df32775e7 (patch) | |
tree | 3871b20359aa56995a4b8974ae5cb6b911dd73f5 /server/lib/requestsScheduler.js | |
parent | 07d932038745e773359fa87bac6be70523f593ee (diff) | |
download | PeerTube-aaf61f3810e6d57c5130af959bd2860df32775e7.tar.gz PeerTube-aaf61f3810e6d57c5130af959bd2860df32775e7.tar.zst PeerTube-aaf61f3810e6d57c5130af959bd2860df32775e7.zip |
Video model refractoring -> use mongoose api
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 | }) |