aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/video/sql
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-06-11 16:02:26 +0200
committerChocobozzz <me@florianbigard.com>2021-06-11 16:02:26 +0200
commit668f864f5a50bd34ffd7c32c91bfff122118d4bf (patch)
tree8ee891b0aee157950b34d5b106135b86206f40d2 /server/models/video/sql
parentb8afe6f0cd32177a3670ac0850db5b58678db5f8 (diff)
downloadPeerTube-668f864f5a50bd34ffd7c32c91bfff122118d4bf.tar.gz
PeerTube-668f864f5a50bd34ffd7c32c91bfff122118d4bf.tar.zst
PeerTube-668f864f5a50bd34ffd7c32c91bfff122118d4bf.zip
Fix live files include
Diffstat (limited to 'server/models/video/sql')
-rw-r--r--server/models/video/sql/shared/abstract-videos-model-query-builder.ts13
-rw-r--r--server/models/video/sql/shared/video-file-query-builder.ts4
-rw-r--r--server/models/video/sql/shared/video-model-builder.ts10
-rw-r--r--server/models/video/sql/videos-model-list-query-builder.ts4
4 files changed, 17 insertions, 14 deletions
diff --git a/server/models/video/sql/shared/abstract-videos-model-query-builder.ts b/server/models/video/sql/shared/abstract-videos-model-query-builder.ts
index d959cb5d0..0d7e64574 100644
--- a/server/models/video/sql/shared/abstract-videos-model-query-builder.ts
+++ b/server/models/video/sql/shared/abstract-videos-model-query-builder.ts
@@ -102,9 +102,8 @@ export class AbstractVideosModelQueryBuilder extends AbstractVideosQueryBuilder
102 } 102 }
103 } 103 }
104 104
105 protected includeWebtorrentFiles (required: boolean) { 105 protected includeWebtorrentFiles () {
106 const joinType = required ? 'INNER' : 'LEFT' 106 this.addJoin('LEFT JOIN "videoFile" AS "VideoFiles" ON "VideoFiles"."videoId" = "video"."id"')
107 this.addJoin(joinType + ' JOIN "videoFile" AS "VideoFiles" ON "VideoFiles"."videoId" = "video"."id"')
108 107
109 this.attributes = { 108 this.attributes = {
110 ...this.attributes, 109 ...this.attributes,
@@ -113,15 +112,13 @@ export class AbstractVideosModelQueryBuilder extends AbstractVideosQueryBuilder
113 } 112 }
114 } 113 }
115 114
116 protected includeStreamingPlaylistFiles (required: boolean) { 115 protected includeStreamingPlaylistFiles () {
117 const joinType = required ? 'INNER' : 'LEFT'
118
119 this.addJoin( 116 this.addJoin(
120 joinType + ' JOIN "videoStreamingPlaylist" AS "VideoStreamingPlaylists" ON "VideoStreamingPlaylists"."videoId" = "video"."id"' 117 'LEFT JOIN "videoStreamingPlaylist" AS "VideoStreamingPlaylists" ON "VideoStreamingPlaylists"."videoId" = "video"."id"'
121 ) 118 )
122 119
123 this.addJoin( 120 this.addJoin(
124 joinType + ' JOIN "videoFile" AS "VideoStreamingPlaylists->VideoFiles" ' + 121 'LEFT JOIN "videoFile" AS "VideoStreamingPlaylists->VideoFiles" ' +
125 'ON "VideoStreamingPlaylists->VideoFiles"."videoStreamingPlaylistId" = "VideoStreamingPlaylists"."id"' 122 'ON "VideoStreamingPlaylists->VideoFiles"."videoStreamingPlaylistId" = "VideoStreamingPlaylists"."id"'
126 ) 123 )
127 124
diff --git a/server/models/video/sql/shared/video-file-query-builder.ts b/server/models/video/sql/shared/video-file-query-builder.ts
index a62fa64f8..6b15c3b69 100644
--- a/server/models/video/sql/shared/video-file-query-builder.ts
+++ b/server/models/video/sql/shared/video-file-query-builder.ts
@@ -32,7 +32,7 @@ export class VideoFileQueryBuilder extends AbstractVideosModelQueryBuilder {
32 '"video"."id"': '' 32 '"video"."id"': ''
33 } 33 }
34 34
35 this.includeWebtorrentFiles(true) 35 this.includeWebtorrentFiles()
36 36
37 if (this.shouldIncludeRedundancies(options)) { 37 if (this.shouldIncludeRedundancies(options)) {
38 this.includeWebTorrentRedundancies() 38 this.includeWebTorrentRedundancies()
@@ -48,7 +48,7 @@ export class VideoFileQueryBuilder extends AbstractVideosModelQueryBuilder {
48 '"video"."id"': '' 48 '"video"."id"': ''
49 } 49 }
50 50
51 this.includeStreamingPlaylistFiles(true) 51 this.includeStreamingPlaylistFiles()
52 52
53 if (this.shouldIncludeRedundancies(options)) { 53 if (this.shouldIncludeRedundancies(options)) {
54 this.includeStreamingPlaylistRedundancies() 54 this.includeStreamingPlaylistRedundancies()
diff --git a/server/models/video/sql/shared/video-model-builder.ts b/server/models/video/sql/shared/video-model-builder.ts
index 467a9378a..cc71192c0 100644
--- a/server/models/video/sql/shared/video-model-builder.ts
+++ b/server/models/video/sql/shared/video-model-builder.ts
@@ -108,9 +108,12 @@ export class VideoModelBuilder {
108 if (!rowsWebTorrentFiles) return 108 if (!rowsWebTorrentFiles) return
109 109
110 for (const row of rowsWebTorrentFiles) { 110 for (const row of rowsWebTorrentFiles) {
111 const id = row['VideoFiles.id']
112 if (!id) continue
113
111 const videoModel = this.videosMemo[row.id] 114 const videoModel = this.videosMemo[row.id]
112 this.addWebTorrentFile(row, videoModel) 115 this.addWebTorrentFile(row, videoModel)
113 this.addRedundancy(row, 'VideoFiles.RedundancyVideos', this.videoFileMemo[row['VideoFiles.id']]) 116 this.addRedundancy(row, 'VideoFiles.RedundancyVideos', this.videoFileMemo[id])
114 } 117 }
115 } 118 }
116 119
@@ -118,6 +121,9 @@ export class VideoModelBuilder {
118 if (!rowsStreamingPlaylist) return 121 if (!rowsStreamingPlaylist) return
119 122
120 for (const row of rowsStreamingPlaylist || []) { 123 for (const row of rowsStreamingPlaylist || []) {
124 const id = row['VideoStreamingPlaylists.id']
125 if (!id) continue
126
121 const videoModel = this.videosMemo[row.id] 127 const videoModel = this.videosMemo[row.id]
122 128
123 this.addStreamingPlaylist(row, videoModel) 129 this.addStreamingPlaylist(row, videoModel)
@@ -125,7 +131,7 @@ export class VideoModelBuilder {
125 this.addRedundancy( 131 this.addRedundancy(
126 row, 132 row,
127 'VideoStreamingPlaylists.RedundancyVideos', 133 'VideoStreamingPlaylists.RedundancyVideos',
128 this.videoStreamingPlaylistMemo[row['VideoStreamingPlaylists.id']] 134 this.videoStreamingPlaylistMemo[id]
129 ) 135 )
130 } 136 }
131 } 137 }
diff --git a/server/models/video/sql/videos-model-list-query-builder.ts b/server/models/video/sql/videos-model-list-query-builder.ts
index 43040fc5e..e61c51de8 100644
--- a/server/models/video/sql/videos-model-list-query-builder.ts
+++ b/server/models/video/sql/videos-model-list-query-builder.ts
@@ -52,8 +52,8 @@ export class VideosModelListQueryBuilder extends AbstractVideosModelQueryBuilder
52 this.includeThumbnails() 52 this.includeThumbnails()
53 53
54 if (options.withFiles) { 54 if (options.withFiles) {
55 this.includeWebtorrentFiles(false) 55 this.includeWebtorrentFiles()
56 this.includeStreamingPlaylistFiles(false) 56 this.includeStreamingPlaylistFiles()
57 } 57 }
58 58
59 if (options.user) { 59 if (options.user) {