From ae9bbed46dbc8d9870c9feb66bbada484c1c7582 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 8 Apr 2019 11:13:49 +0200 Subject: Update P2P media loader peer version --- server/models/video/video-file.ts | 24 ++++++++++++++++++++++++ server/models/video/video-streaming-playlist.ts | 22 +++++++++++++++++++--- 2 files changed, 43 insertions(+), 3 deletions(-) (limited to 'server/models') diff --git a/server/models/video/video-file.ts b/server/models/video/video-file.ts index b861b0704..c14d96bc5 100644 --- a/server/models/video/video-file.ts +++ b/server/models/video/video-file.ts @@ -23,6 +23,7 @@ import { throwIfNotValid } from '../utils' import { VideoModel } from './video' import * as Sequelize from 'sequelize' import { VideoRedundancyModel } from '../redundancy/video-redundancy' +import { VideoStreamingPlaylistModel } from './video-streaming-playlist' @Table({ tableName: 'videoFile', @@ -120,6 +121,29 @@ export class VideoFileModel extends Model { return VideoFileModel.findByPk(id, options) } + static listByStreamingPlaylist (streamingPlaylistId: number, transaction: Sequelize.Transaction) { + const query = { + include: [ + { + model: VideoModel.unscoped(), + required: true, + include: [ + { + model: VideoStreamingPlaylistModel.unscoped(), + required: true, + where: { + id: streamingPlaylistId + } + } + ] + } + ], + transaction + } + + return VideoFileModel.findAll(query) + } + static async getStats () { let totalLocalVideoFilesSize = await VideoFileModel.sum('size', { include: [ diff --git a/server/models/video/video-streaming-playlist.ts b/server/models/video/video-streaming-playlist.ts index b147aca36..0333755c5 100644 --- a/server/models/video/video-streaming-playlist.ts +++ b/server/models/video/video-streaming-playlist.ts @@ -6,7 +6,7 @@ import * as Sequelize from 'sequelize' import { VideoRedundancyModel } from '../redundancy/video-redundancy' import { VideoStreamingPlaylistType } from '../../../shared/models/videos/video-streaming-playlist.type' import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc' -import { CONSTRAINTS_FIELDS, STATIC_PATHS } from '../../initializers' +import { CONSTRAINTS_FIELDS, STATIC_PATHS, P2P_MEDIA_LOADER_PEER_VERSION } from '../../initializers' import { VideoFileModel } from './video-file' import { join } from 'path' import { sha1 } from '../../helpers/core-utils' @@ -49,6 +49,10 @@ export class VideoStreamingPlaylistModel extends Model throwIfNotValid(value, isActivityPubUrlValid, 'segments sha256 url')) @Column @@ -92,14 +96,26 @@ export class VideoStreamingPlaylistModel extends Model