diff options
author | Chocobozzz <me@florianbigard.com> | 2022-07-13 10:15:41 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2022-07-13 10:15:41 +0200 |
commit | 3b0525106d8742b5ebd6962219eaf105435f6fb9 (patch) | |
tree | d131525954638b8a144a2ed1217eb01feff54590 /server/models/video | |
parent | b0f4204266057316c11fc034da0ce86a212dc0b3 (diff) | |
download | PeerTube-3b0525106d8742b5ebd6962219eaf105435f6fb9.tar.gz PeerTube-3b0525106d8742b5ebd6962219eaf105435f6fb9.tar.zst PeerTube-3b0525106d8742b5ebd6962219eaf105435f6fb9.zip |
Prevent duplicated HLS playlist on transcoding
Diffstat (limited to 'server/models/video')
-rw-r--r-- | server/models/video/video-streaming-playlist.ts | 11 |
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 @@ | |||
1 | import memoizee from 'memoizee' | 1 | import memoizee from 'memoizee' |
2 | import { join } from 'path' | 2 | import { join } from 'path' |
3 | import { Op } from 'sequelize' | 3 | import { Op, Transaction } from 'sequelize' |
4 | import { | 4 | import { |
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 }) |