mirror of https://github.com/Chocobozzz/PeerTube
Server: Fix video propagation with transcoding enabled
parent
fce897f326
commit
62326afb15
|
@ -379,6 +379,9 @@ function addVideo (req, res, videoFile, finalCallback) {
|
|||
},
|
||||
|
||||
function sendToFriends (t, video, callback) {
|
||||
// Let transcoding job send the video to friends because the videofile extension might change
|
||||
if (constants.CONFIG.TRANSCODING.ENABLED === true) return callback(null, t)
|
||||
|
||||
video.toAddRemoteJSON(function (err, remoteVideo) {
|
||||
if (err) return callback(err)
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
const db = require('../../../initializers/database')
|
||||
const logger = require('../../../helpers/logger')
|
||||
const friends = require('../../../lib/friends')
|
||||
|
||||
const VideoTranscoderHandler = {
|
||||
process,
|
||||
|
@ -12,21 +13,29 @@ const VideoTranscoderHandler = {
|
|||
// ---------------------------------------------------------------------------
|
||||
|
||||
function process (data, callback) {
|
||||
db.Video.load(data.id, function (err, video) {
|
||||
db.Video.loadAndPopulateAuthorAndPodAndTags(data.id, function (err, video) {
|
||||
if (err) return callback(err)
|
||||
|
||||
video.transcodeVideofile(callback)
|
||||
video.transcodeVideofile(function (err) {
|
||||
return callback(err, video)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function onError (err, jobId, callback) {
|
||||
function onError (err, jobId, video, callback) {
|
||||
logger.error('Error when transcoding video file in job %d.', jobId, { error: err })
|
||||
return callback()
|
||||
}
|
||||
|
||||
function onSuccess (data, jobId, callback) {
|
||||
function onSuccess (data, jobId, video, callback) {
|
||||
logger.info('Job %d is a success.', jobId)
|
||||
return callback()
|
||||
|
||||
video.toAddRemoteJSON(function (err, remoteVideo) {
|
||||
if (err) return callback(err)
|
||||
|
||||
// Now we'll add the video's meta data to our friends
|
||||
friends.addVideoToFriends(remoteVideo, null, callback)
|
||||
})
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
|
|
@ -76,31 +76,31 @@ function processJob (job, callback) {
|
|||
return jobHandler.process(job.handlerInputData, function (err, result) {
|
||||
if (err) {
|
||||
logger.error('Error in job handler %s.', job.handlerName, { error: err })
|
||||
return onJobError(jobHandler, job, callback)
|
||||
return onJobError(jobHandler, job, result, callback)
|
||||
}
|
||||
|
||||
return onJobSuccess(jobHandler, job, callback)
|
||||
return onJobSuccess(jobHandler, job, result, callback)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function onJobError (jobHandler, job, callback) {
|
||||
function onJobError (jobHandler, job, jobResult, callback) {
|
||||
job.state = constants.JOB_STATES.ERROR
|
||||
|
||||
job.save().asCallback(function (err) {
|
||||
if (err) return cannotSaveJobError(err, callback)
|
||||
|
||||
return jobHandler.onError(err, job.id, callback)
|
||||
return jobHandler.onError(err, job.id, jobResult, callback)
|
||||
})
|
||||
}
|
||||
|
||||
function onJobSuccess (jobHandler, job, callback) {
|
||||
function onJobSuccess (jobHandler, job, jobResult, callback) {
|
||||
job.state = constants.JOB_STATES.SUCCESS
|
||||
|
||||
job.save().asCallback(function (err) {
|
||||
if (err) return cannotSaveJobError(err, callback)
|
||||
|
||||
return jobHandler.onSuccess(err, job.id, callback)
|
||||
return jobHandler.onSuccess(err, job.id, jobResult, callback)
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -76,6 +76,7 @@ describe('Test multiple pods', function () {
|
|||
|
||||
describe('Should upload the video and propagate on each pod', function () {
|
||||
it('Should upload the video on pod 1 and propagate on each pod', function (done) {
|
||||
// Pod 1 has video transcoding activated
|
||||
this.timeout(15000)
|
||||
|
||||
series([
|
||||
|
@ -152,7 +153,7 @@ describe('Test multiple pods', function () {
|
|||
})
|
||||
|
||||
it('Should upload the video on pod 2 and propagate on each pod', function (done) {
|
||||
this.timeout(15000)
|
||||
this.timeout(30000)
|
||||
|
||||
series([
|
||||
function (next) {
|
||||
|
@ -169,7 +170,7 @@ describe('Test multiple pods', function () {
|
|||
videosUtils.uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes, next)
|
||||
},
|
||||
function (next) {
|
||||
setTimeout(next, 11000)
|
||||
setTimeout(next, 22000)
|
||||
}],
|
||||
// All pods should have this video
|
||||
function (err) {
|
||||
|
|
Loading…
Reference in New Issue