diff options
author | Chocobozzz <me@florianbigard.com> | 2021-02-02 08:48:48 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-02-02 08:50:30 +0100 |
commit | 89613cb444b4e1601d202153d0ec8635392ec872 (patch) | |
tree | b8a5835253028f563ee9afbd2561032c94ec58b4 /server/models | |
parent | fb7b009d6368acacade236b74406709851a0eaa5 (diff) | |
download | PeerTube-89613cb444b4e1601d202153d0ec8635392ec872.tar.gz PeerTube-89613cb444b4e1601d202153d0ec8635392ec872.tar.zst PeerTube-89613cb444b4e1601d202153d0ec8635392ec872.zip |
Purge entire video from redundancy
Diffstat (limited to 'server/models')
-rw-r--r-- | server/models/redundancy/video-redundancy.ts | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/server/models/redundancy/video-redundancy.ts b/server/models/redundancy/video-redundancy.ts index 98c6ff134..74895fe30 100644 --- a/server/models/redundancy/video-redundancy.ts +++ b/server/models/redundancy/video-redundancy.ts | |||
@@ -185,6 +185,57 @@ export class VideoRedundancyModel extends Model { | |||
185 | return VideoRedundancyModel.scope(ScopeNames.WITH_VIDEO).findOne(query) | 185 | return VideoRedundancyModel.scope(ScopeNames.WITH_VIDEO).findOne(query) |
186 | } | 186 | } |
187 | 187 | ||
188 | static async listLocalByVideoId (videoId: number): Promise<MVideoRedundancyVideo[]> { | ||
189 | const actor = await getServerActor() | ||
190 | |||
191 | const queryStreamingPlaylist = { | ||
192 | where: { | ||
193 | actorId: actor.id | ||
194 | }, | ||
195 | include: [ | ||
196 | { | ||
197 | model: VideoStreamingPlaylistModel.unscoped(), | ||
198 | required: true, | ||
199 | include: [ | ||
200 | { | ||
201 | model: VideoModel.unscoped(), | ||
202 | required: true, | ||
203 | where: { | ||
204 | id: videoId | ||
205 | } | ||
206 | } | ||
207 | ] | ||
208 | } | ||
209 | ] | ||
210 | } | ||
211 | |||
212 | const queryFiles = { | ||
213 | where: { | ||
214 | actorId: actor.id | ||
215 | }, | ||
216 | include: [ | ||
217 | { | ||
218 | model: VideoFileModel, | ||
219 | required: true, | ||
220 | include: [ | ||
221 | { | ||
222 | model: VideoModel, | ||
223 | required: true, | ||
224 | where: { | ||
225 | id: videoId | ||
226 | } | ||
227 | } | ||
228 | ] | ||
229 | } | ||
230 | ] | ||
231 | } | ||
232 | |||
233 | return Promise.all([ | ||
234 | VideoRedundancyModel.findAll(queryStreamingPlaylist), | ||
235 | VideoRedundancyModel.findAll(queryFiles) | ||
236 | ]).then(([ r1, r2 ]) => r1.concat(r2)) | ||
237 | } | ||
238 | |||
188 | static async loadLocalByStreamingPlaylistId (videoStreamingPlaylistId: number): Promise<MVideoRedundancyVideo> { | 239 | static async loadLocalByStreamingPlaylistId (videoStreamingPlaylistId: number): Promise<MVideoRedundancyVideo> { |
189 | const actor = await getServerActor() | 240 | const actor = await getServerActor() |
190 | 241 | ||