From 764b1a14fc494f2cfd7ea590d2f07b01df65c7ad Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 23 Jul 2021 11:20:00 +0200 Subject: Use random names for VOD HLS playlists --- server/controllers/api/videos/upload.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'server/controllers/api') diff --git a/server/controllers/api/videos/upload.ts b/server/controllers/api/videos/upload.ts index 7792ae3fc..408f677ff 100644 --- a/server/controllers/api/videos/upload.ts +++ b/server/controllers/api/videos/upload.ts @@ -209,10 +209,12 @@ async function addVideo (options: { }) createTorrentFederate(video, videoFile) + .then(() => { + if (video.state !== VideoState.TO_TRANSCODE) return - if (video.state === VideoState.TO_TRANSCODE) { - await addOptimizeOrMergeAudioJob(videoCreated, videoFile, user) - } + return addOptimizeOrMergeAudioJob(videoCreated, videoFile, user) + }) + .catch(err => logger.error('Cannot add optimize/merge audio job for %s.', videoCreated.uuid, { err, ...lTags(videoCreated.uuid) })) Hooks.runAction('action:api.video.uploaded', { video: videoCreated }) @@ -259,9 +261,9 @@ async function createTorrentAndSetInfoHashAsync (video: MVideo, fileArg: MVideoF return refreshedFile.save() } -function createTorrentFederate (video: MVideoFullLight, videoFile: MVideoFile): void { +function createTorrentFederate (video: MVideoFullLight, videoFile: MVideoFile) { // Create the torrent file in async way because it could be long - createTorrentAndSetInfoHashAsync(video, videoFile) + return createTorrentAndSetInfoHashAsync(video, videoFile) .catch(err => logger.error('Cannot create torrent file for video %s', video.url, { err, ...lTags(video.uuid) })) .then(() => VideoModel.loadAndPopulateAccountAndServerAndTags(video.id)) .then(refreshedVideo => { -- cgit v1.2.3