From 3b0525106d8742b5ebd6962219eaf105435f6fb9 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 13 Jul 2022 10:15:41 +0200 Subject: Prevent duplicated HLS playlist on transcoding --- server/models/video/video-streaming-playlist.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'server/models/video/video-streaming-playlist.ts') 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 @@ import memoizee from 'memoizee' import { join } from 'path' -import { Op } from 'sequelize' +import { Op, Transaction } from 'sequelize' import { AllowNull, BelongsTo, @@ -180,19 +180,20 @@ export class VideoStreamingPlaylistModel extends Model { + static loadHLSPlaylistByVideo (videoId: number, transaction?: Transaction): Promise { const options = { where: { type: VideoStreamingPlaylistType.HLS, videoId - } + }, + transaction } return VideoStreamingPlaylistModel.findOne(options) } - static async loadOrGenerate (video: MVideo) { - let playlist = await VideoStreamingPlaylistModel.loadHLSPlaylistByVideo(video.id) + static async loadOrGenerate (video: MVideo, transaction?: Transaction) { + let playlist = await VideoStreamingPlaylistModel.loadHLSPlaylistByVideo(video.id, transaction) if (!playlist) playlist = new VideoStreamingPlaylistModel() return Object.assign(playlist, { videoId: video.id, Video: video }) -- cgit v1.2.3