Fix live files include

pull/4126/head
Chocobozzz 2021-06-11 16:02:26 +02:00
parent b8afe6f0cd
commit 668f864f5a
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
5 changed files with 18 additions and 15 deletions

View File

@ -102,9 +102,8 @@ export class AbstractVideosModelQueryBuilder extends AbstractVideosQueryBuilder
}
}
protected includeWebtorrentFiles (required: boolean) {
const joinType = required ? 'INNER' : 'LEFT'
this.addJoin(joinType + ' JOIN "videoFile" AS "VideoFiles" ON "VideoFiles"."videoId" = "video"."id"')
protected includeWebtorrentFiles () {
this.addJoin('LEFT JOIN "videoFile" AS "VideoFiles" ON "VideoFiles"."videoId" = "video"."id"')
this.attributes = {
...this.attributes,
@ -113,15 +112,13 @@ export class AbstractVideosModelQueryBuilder extends AbstractVideosQueryBuilder
}
}
protected includeStreamingPlaylistFiles (required: boolean) {
const joinType = required ? 'INNER' : 'LEFT'
protected includeStreamingPlaylistFiles () {
this.addJoin(
joinType + ' JOIN "videoStreamingPlaylist" AS "VideoStreamingPlaylists" ON "VideoStreamingPlaylists"."videoId" = "video"."id"'
'LEFT JOIN "videoStreamingPlaylist" AS "VideoStreamingPlaylists" ON "VideoStreamingPlaylists"."videoId" = "video"."id"'
)
this.addJoin(
joinType + ' JOIN "videoFile" AS "VideoStreamingPlaylists->VideoFiles" ' +
'LEFT JOIN "videoFile" AS "VideoStreamingPlaylists->VideoFiles" ' +
'ON "VideoStreamingPlaylists->VideoFiles"."videoStreamingPlaylistId" = "VideoStreamingPlaylists"."id"'
)

View File

@ -32,7 +32,7 @@ export class VideoFileQueryBuilder extends AbstractVideosModelQueryBuilder {
'"video"."id"': ''
}
this.includeWebtorrentFiles(true)
this.includeWebtorrentFiles()
if (this.shouldIncludeRedundancies(options)) {
this.includeWebTorrentRedundancies()
@ -48,7 +48,7 @@ export class VideoFileQueryBuilder extends AbstractVideosModelQueryBuilder {
'"video"."id"': ''
}
this.includeStreamingPlaylistFiles(true)
this.includeStreamingPlaylistFiles()
if (this.shouldIncludeRedundancies(options)) {
this.includeStreamingPlaylistRedundancies()

View File

@ -108,9 +108,12 @@ export class VideoModelBuilder {
if (!rowsWebTorrentFiles) return
for (const row of rowsWebTorrentFiles) {
const id = row['VideoFiles.id']
if (!id) continue
const videoModel = this.videosMemo[row.id]
this.addWebTorrentFile(row, videoModel)
this.addRedundancy(row, 'VideoFiles.RedundancyVideos', this.videoFileMemo[row['VideoFiles.id']])
this.addRedundancy(row, 'VideoFiles.RedundancyVideos', this.videoFileMemo[id])
}
}
@ -118,6 +121,9 @@ export class VideoModelBuilder {
if (!rowsStreamingPlaylist) return
for (const row of rowsStreamingPlaylist || []) {
const id = row['VideoStreamingPlaylists.id']
if (!id) continue
const videoModel = this.videosMemo[row.id]
this.addStreamingPlaylist(row, videoModel)
@ -125,7 +131,7 @@ export class VideoModelBuilder {
this.addRedundancy(
row,
'VideoStreamingPlaylists.RedundancyVideos',
this.videoStreamingPlaylistMemo[row['VideoStreamingPlaylists.id']]
this.videoStreamingPlaylistMemo[id]
)
}
}

View File

@ -52,8 +52,8 @@ export class VideosModelListQueryBuilder extends AbstractVideosModelQueryBuilder
this.includeThumbnails()
if (options.withFiles) {
this.includeWebtorrentFiles(false)
this.includeStreamingPlaylistFiles(false)
this.includeWebtorrentFiles()
this.includeStreamingPlaylistFiles()
}
if (options.user) {

View File

@ -27,7 +27,7 @@ import {
const expect = chai.expect
describe('Permenant live', function () {
describe('Permanent live', function () {
let servers: ServerInfo[] = []
let videoUUID: string