Fix integrity with transcoding jobs
This commit is contained in:
parent
911238e343
commit
4077df72c6
|
@ -29,17 +29,22 @@ async function onSuccess (jobId: number, video: VideoInstance) {
|
||||||
|
|
||||||
logger.info('Job %d is a success.', jobId)
|
logger.info('Job %d is a success.', jobId)
|
||||||
|
|
||||||
const remoteVideo = await video.toAddRemoteJSON()
|
// Maybe the video changed in database, refresh it
|
||||||
|
const videoDatabase = await db.Video.loadByUUIDAndPopulateAuthorAndPodAndTags(video.uuid)
|
||||||
|
// Video does not exist anymore
|
||||||
|
if (!videoDatabase) return undefined
|
||||||
|
|
||||||
|
const remoteVideo = await videoDatabase.toAddRemoteJSON()
|
||||||
|
|
||||||
// Now we'll add the video's meta data to our friends
|
// Now we'll add the video's meta data to our friends
|
||||||
await addVideoToFriends(remoteVideo, null)
|
await addVideoToFriends(remoteVideo, null)
|
||||||
|
|
||||||
const originalFileHeight = await video.getOriginalFileHeight()
|
const originalFileHeight = await videoDatabase.getOriginalFileHeight()
|
||||||
// Create transcoding jobs if there are enabled resolutions
|
// Create transcoding jobs if there are enabled resolutions
|
||||||
|
|
||||||
const resolutionsEnabled = computeResolutionsToTranscode(originalFileHeight)
|
const resolutionsEnabled = computeResolutionsToTranscode(originalFileHeight)
|
||||||
logger.info(
|
logger.info(
|
||||||
'Resolutions computed for video %s and origin file height of %d.', video.uuid, originalFileHeight,
|
'Resolutions computed for video %s and origin file height of %d.', videoDatabase.uuid, originalFileHeight,
|
||||||
{ resolutions: resolutionsEnabled }
|
{ resolutions: resolutionsEnabled }
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -50,7 +55,7 @@ async function onSuccess (jobId: number, video: VideoInstance) {
|
||||||
|
|
||||||
for (const resolution of resolutionsEnabled) {
|
for (const resolution of resolutionsEnabled) {
|
||||||
const dataInput = {
|
const dataInput = {
|
||||||
videoUUID: video.uuid,
|
videoUUID: videoDatabase.uuid,
|
||||||
resolution
|
resolution
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,7 +66,7 @@ async function onSuccess (jobId: number, video: VideoInstance) {
|
||||||
await Promise.all(tasks)
|
await Promise.all(tasks)
|
||||||
})
|
})
|
||||||
|
|
||||||
logger.info('Transcoding jobs created for uuid %s.', video.uuid, { resolutionsEnabled })
|
logger.info('Transcoding jobs created for uuid %s.', videoDatabase.uuid, { resolutionsEnabled })
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
logger.warn('Cannot transcode the video.', err)
|
logger.warn('Cannot transcode the video.', err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,15 +22,22 @@ function onError (err: Error, jobId: number) {
|
||||||
return Promise.resolve()
|
return Promise.resolve()
|
||||||
}
|
}
|
||||||
|
|
||||||
function onSuccess (jobId: number, video: VideoInstance) {
|
async function onSuccess (jobId: number, video: VideoInstance) {
|
||||||
if (video === undefined) return undefined
|
if (video === undefined) return undefined
|
||||||
|
|
||||||
logger.info('Job %d is a success.', jobId)
|
logger.info('Job %d is a success.', jobId)
|
||||||
|
|
||||||
const remoteVideo = video.toUpdateRemoteJSON()
|
// Maybe the video changed in database, refresh it
|
||||||
|
const videoDatabase = await db.Video.loadByUUIDAndPopulateAuthorAndPodAndTags(video.uuid)
|
||||||
|
// Video does not exist anymore
|
||||||
|
if (!videoDatabase) return undefined
|
||||||
|
|
||||||
|
const remoteVideo = videoDatabase.toUpdateRemoteJSON()
|
||||||
|
|
||||||
// Now we'll add the video's meta data to our friends
|
// Now we'll add the video's meta data to our friends
|
||||||
return updateVideoToFriends(remoteVideo, null)
|
await updateVideoToFriends(remoteVideo, null)
|
||||||
|
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
Loading…
Reference in New Issue