aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/transcoding/transcoding.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2022-07-13 10:15:41 +0200
committerChocobozzz <me@florianbigard.com>2022-07-13 10:15:41 +0200
commit3b0525106d8742b5ebd6962219eaf105435f6fb9 (patch)
treed131525954638b8a144a2ed1217eb01feff54590 /server/lib/transcoding/transcoding.ts
parentb0f4204266057316c11fc034da0ce86a212dc0b3 (diff)
downloadPeerTube-3b0525106d8742b5ebd6962219eaf105435f6fb9.tar.gz
PeerTube-3b0525106d8742b5ebd6962219eaf105435f6fb9.tar.zst
PeerTube-3b0525106d8742b5ebd6962219eaf105435f6fb9.zip
Prevent duplicated HLS playlist on transcoding
Diffstat (limited to 'server/lib/transcoding/transcoding.ts')
-rw-r--r--server/lib/transcoding/transcoding.ts30
1 files changed, 19 insertions, 11 deletions
diff --git a/server/lib/transcoding/transcoding.ts b/server/lib/transcoding/transcoding.ts
index 9a15f8613..b64ce6e1f 100644
--- a/server/lib/transcoding/transcoding.ts
+++ b/server/lib/transcoding/transcoding.ts
@@ -29,6 +29,8 @@ import {
29} from '../paths' 29} from '../paths'
30import { VideoPathManager } from '../video-path-manager' 30import { VideoPathManager } from '../video-path-manager'
31import { VideoTranscodingProfilesManager } from './default-transcoding-profiles' 31import { VideoTranscodingProfilesManager } from './default-transcoding-profiles'
32import { retryTransactionWrapper } from '@server/helpers/database-utils'
33import { sequelizeTypescript } from '@server/initializers/database'
32 34
33/** 35/**
34 * 36 *
@@ -309,22 +311,28 @@ async function generateHlsPlaylistCommon (options: {
309 await transcodeVOD(transcodeOptions) 311 await transcodeVOD(transcodeOptions)
310 312
311 // Create or update the playlist 313 // Create or update the playlist
312 const playlist = await VideoStreamingPlaylistModel.loadOrGenerate(video) 314 const playlist = await retryTransactionWrapper(() => {
315 return sequelizeTypescript.transaction(async transaction => {
316 const playlist = await VideoStreamingPlaylistModel.loadOrGenerate(video, transaction)
313 317
314 if (!playlist.playlistFilename) { 318 if (!playlist.playlistFilename) {
315 playlist.playlistFilename = generateHLSMasterPlaylistFilename(video.isLive) 319 playlist.playlistFilename = generateHLSMasterPlaylistFilename(video.isLive)
316 } 320 }
317 321
318 if (!playlist.segmentsSha256Filename) { 322 if (!playlist.segmentsSha256Filename) {
319 playlist.segmentsSha256Filename = generateHlsSha256SegmentsFilename(video.isLive) 323 playlist.segmentsSha256Filename = generateHlsSha256SegmentsFilename(video.isLive)
320 } 324 }
321 325
322 playlist.p2pMediaLoaderInfohashes = [] 326 playlist.p2pMediaLoaderInfohashes = []
323 playlist.p2pMediaLoaderPeerVersion = P2P_MEDIA_LOADER_PEER_VERSION 327 playlist.p2pMediaLoaderPeerVersion = P2P_MEDIA_LOADER_PEER_VERSION
324 328
325 playlist.type = VideoStreamingPlaylistType.HLS 329 playlist.type = VideoStreamingPlaylistType.HLS
326 330
327 await playlist.save() 331 await playlist.save({ transaction })
332
333 return playlist
334 })
335 })
328 336
329 // Build the new playlist file 337 // Build the new playlist file
330 const extname = extnameUtil(videoFilename) 338 const extname = extnameUtil(videoFilename)