mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-05 10:49:28 +02:00
Basic video redundancy implementation
This commit is contained in:
parent
a651038487
commit
c48e82b5e0
77 changed files with 1667 additions and 287 deletions
|
@ -1,5 +1,18 @@
|
|||
import { values } from 'lodash'
|
||||
import { AllowNull, BelongsTo, Column, CreatedAt, DataType, Default, ForeignKey, Is, Model, Table, UpdatedAt } from 'sequelize-typescript'
|
||||
import {
|
||||
AllowNull,
|
||||
BelongsTo,
|
||||
Column,
|
||||
CreatedAt,
|
||||
DataType,
|
||||
Default,
|
||||
ForeignKey,
|
||||
HasMany,
|
||||
Is,
|
||||
Model,
|
||||
Table,
|
||||
UpdatedAt
|
||||
} from 'sequelize-typescript'
|
||||
import {
|
||||
isVideoFileInfoHashValid,
|
||||
isVideoFileResolutionValid,
|
||||
|
@ -10,6 +23,7 @@ import { CONSTRAINTS_FIELDS } from '../../initializers'
|
|||
import { throwIfNotValid } from '../utils'
|
||||
import { VideoModel } from './video'
|
||||
import * as Sequelize from 'sequelize'
|
||||
import { VideoRedundancyModel } from '../redundancy/video-redundancy'
|
||||
|
||||
@Table({
|
||||
tableName: 'videoFile',
|
||||
|
@ -70,6 +84,15 @@ export class VideoFileModel extends Model<VideoFileModel> {
|
|||
})
|
||||
Video: VideoModel
|
||||
|
||||
@HasMany(() => VideoRedundancyModel, {
|
||||
foreignKey: {
|
||||
allowNull: false
|
||||
},
|
||||
onDelete: 'CASCADE',
|
||||
hooks: true
|
||||
})
|
||||
RedundancyVideos: VideoRedundancyModel[]
|
||||
|
||||
static isInfohashExists (infoHash: string) {
|
||||
const query = 'SELECT 1 FROM "videoFile" WHERE "infoHash" = $infoHash LIMIT 1'
|
||||
const options = {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue