aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models
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/models
parentb0f4204266057316c11fc034da0ce86a212dc0b3 (diff)
downloadPeerTube-3b0525106d8742b5ebd6962219eaf105435f6fb9.tar.gz
PeerTube-3b0525106d8742b5ebd6962219eaf105435f6fb9.tar.zst
PeerTube-3b0525106d8742b5ebd6962219eaf105435f6fb9.zip
Prevent duplicated HLS playlist on transcoding
Diffstat (limited to 'server/models')
-rw-r--r--server/models/video/video-streaming-playlist.ts11
1 files changed, 6 insertions, 5 deletions
diff --git a/server/models/video/video-streaming-playlist.ts b/server/models/video/video-streaming-playlist.ts
index 9957ffee3..2c4dbd8ec 100644
--- a/server/models/video/video-streaming-playlist.ts
+++ b/server/models/video/video-streaming-playlist.ts
@@ -1,6 +1,6 @@
1import memoizee from 'memoizee' 1import memoizee from 'memoizee'
2import { join } from 'path' 2import { join } from 'path'
3import { Op } from 'sequelize' 3import { Op, Transaction } from 'sequelize'
4import { 4import {
5 AllowNull, 5 AllowNull,
6 BelongsTo, 6 BelongsTo,
@@ -180,19 +180,20 @@ export class VideoStreamingPlaylistModel extends Model<Partial<AttributesOnly<Vi
180 return VideoStreamingPlaylistModel.findByPk(id, options) 180 return VideoStreamingPlaylistModel.findByPk(id, options)
181 } 181 }
182 182
183 static loadHLSPlaylistByVideo (videoId: number): Promise<MStreamingPlaylist> { 183 static loadHLSPlaylistByVideo (videoId: number, transaction?: Transaction): Promise<MStreamingPlaylist> {
184 const options = { 184 const options = {
185 where: { 185 where: {
186 type: VideoStreamingPlaylistType.HLS, 186 type: VideoStreamingPlaylistType.HLS,
187 videoId 187 videoId
188 } 188 },
189 transaction
189 } 190 }
190 191
191 return VideoStreamingPlaylistModel.findOne(options) 192 return VideoStreamingPlaylistModel.findOne(options)
192 } 193 }
193 194
194 static async loadOrGenerate (video: MVideo) { 195 static async loadOrGenerate (video: MVideo, transaction?: Transaction) {
195 let playlist = await VideoStreamingPlaylistModel.loadHLSPlaylistByVideo(video.id) 196 let playlist = await VideoStreamingPlaylistModel.loadHLSPlaylistByVideo(video.id, transaction)
196 if (!playlist) playlist = new VideoStreamingPlaylistModel() 197 if (!playlist) playlist = new VideoStreamingPlaylistModel()
197 198
198 return Object.assign(playlist, { videoId: video.id, Video: video }) 199 return Object.assign(playlist, { videoId: video.id, Video: video })