1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-05 02:39:33 +02:00

Server: pod removing refractoring

This commit is contained in:
Chocobozzz 2016-10-21 11:20:45 +02:00
parent 792b893ed4
commit 80a6c9e76f
6 changed files with 27 additions and 89 deletions

View file

@ -1,6 +1,5 @@
'use strict'
const each = require('async/each')
const express = require('express')
const mongoose = require('mongoose')
const waterfall = require('async/waterfall')
@ -17,7 +16,6 @@ const signatureValidator = middlewares.validators.remote.signature
const router = express.Router()
const Pod = mongoose.model('Pod')
const Video = mongoose.model('Video')
router.get('/', listPods)
router.post('/',
@ -117,27 +115,7 @@ function removePods (req, res, next) {
},
function removePod (pod, callback) {
pod.remove(function (err) {
// Be sure we only return one argument in the callback
return callback(err)
})
},
function (callback) {
Video.listByUrls([ url ], function (err, videosList) {
if (err) {
logger.error('Cannot list videos from url.', { error: err })
return callback(err)
}
return callback(null, videosList)
})
},
function removeTheRemoteVideos (videosList, callback) {
each(videosList, function (video, callbackEach) {
video.remove(callbackEach)
}, callback)
pod.remove(callback)
}
], function (err) {
if (err) return next(err)