mirror of https://github.com/Chocobozzz/PeerTube
Fix requests ordering between pods
parent
0890478c5c
commit
6666aad459
|
@ -39,6 +39,8 @@ function remoteVideos (req, res, next) {
|
||||||
addRemoteVideo(videoData, callbackEach)
|
addRemoteVideo(videoData, callbackEach)
|
||||||
} else if (request.type === 'remove') {
|
} else if (request.type === 'remove') {
|
||||||
removeRemoteVideo(videoData, fromUrl, callbackEach)
|
removeRemoteVideo(videoData, fromUrl, callbackEach)
|
||||||
|
} else {
|
||||||
|
logger.error('Unkown remote request type %s.', request.type)
|
||||||
}
|
}
|
||||||
}, function (err) {
|
}, function (err) {
|
||||||
if (err) logger.error('Error managing remote videos.', { error: err })
|
if (err) logger.error('Error managing remote videos.', { error: err })
|
||||||
|
@ -49,6 +51,8 @@ function remoteVideos (req, res, next) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function addRemoteVideo (videoToCreateData, callback) {
|
function addRemoteVideo (videoToCreateData, callback) {
|
||||||
|
logger.debug('Adding remote video %s.', videoToCreateData.magnetUri)
|
||||||
|
|
||||||
// Mongoose pre hook will automatically create the thumbnail on disk
|
// Mongoose pre hook will automatically create the thumbnail on disk
|
||||||
videoToCreateData.thumbnail = videoToCreateData.thumbnailBase64
|
videoToCreateData.thumbnail = videoToCreateData.thumbnailBase64
|
||||||
|
|
||||||
|
@ -64,7 +68,13 @@ function removeRemoteVideo (videoToRemoveData, fromUrl, callback) {
|
||||||
return callback(err)
|
return callback(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (videosList.length === 0) {
|
||||||
|
logger.error('No remote video was found for this pod.', { magnetUri: videoToRemoveData.magnetUri, podUrl: fromUrl })
|
||||||
|
}
|
||||||
|
|
||||||
async.each(videosList, function (video, callbackEach) {
|
async.each(videosList, function (video, callbackEach) {
|
||||||
|
logger.debug('Removing remote video %s.', video.magnetUri)
|
||||||
|
|
||||||
video.remove(callbackEach)
|
video.remove(callbackEach)
|
||||||
}, callback)
|
}, callback)
|
||||||
})
|
})
|
||||||
|
|
|
@ -270,7 +270,7 @@ function updatePodsScore (goodPods, badPods) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function list (callback) {
|
function list (callback) {
|
||||||
this.find({ }, { _id: 1, request: 1, to: 1 }, callback)
|
this.find({ }, { _id: 1, request: 1, to: 1 }).sort({ _id: 1 }).exec(callback)
|
||||||
}
|
}
|
||||||
|
|
||||||
function removeAll (callback) {
|
function removeAll (callback) {
|
||||||
|
|
|
@ -10,6 +10,7 @@ const request = require('supertest')
|
||||||
const testUtils = {
|
const testUtils = {
|
||||||
dateIsValid: dateIsValid,
|
dateIsValid: dateIsValid,
|
||||||
flushTests: flushTests,
|
flushTests: flushTests,
|
||||||
|
getAllVideosListBy: getAllVideosListBy,
|
||||||
getFriendsList: getFriendsList,
|
getFriendsList: getFriendsList,
|
||||||
getVideo: getVideo,
|
getVideo: getVideo,
|
||||||
getVideosList: getVideosList,
|
getVideosList: getVideosList,
|
||||||
|
@ -45,6 +46,20 @@ function flushTests (callback) {
|
||||||
exec('npm run clean:server:test', callback)
|
exec('npm run clean:server:test', callback)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getAllVideosListBy (url, end) {
|
||||||
|
const path = '/api/v1/videos'
|
||||||
|
|
||||||
|
request(url)
|
||||||
|
.get(path)
|
||||||
|
.query({ sort: 'createdDate' })
|
||||||
|
.query({ start: 0 })
|
||||||
|
.query({ count: 10000 })
|
||||||
|
.set('Accept', 'application/json')
|
||||||
|
.expect(200)
|
||||||
|
.expect('Content-Type', /json/)
|
||||||
|
.end(end)
|
||||||
|
}
|
||||||
|
|
||||||
function getFriendsList (url, end) {
|
function getFriendsList (url, end) {
|
||||||
const path = '/api/v1/pods/'
|
const path = '/api/v1/pods/'
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue