aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models
diff options
context:
space:
mode:
Diffstat (limited to 'server/models')
-rw-r--r--server/models/video/video-file.ts15
1 files changed, 15 insertions, 0 deletions
diff --git a/server/models/video/video-file.ts b/server/models/video/video-file.ts
index f5a2b6c1f..3bc4855f3 100644
--- a/server/models/video/video-file.ts
+++ b/server/models/video/video-file.ts
@@ -9,6 +9,7 @@ import {
9import { CONSTRAINTS_FIELDS } from '../../initializers' 9import { CONSTRAINTS_FIELDS } from '../../initializers'
10import { throwIfNotValid } from '../utils' 10import { throwIfNotValid } from '../utils'
11import { VideoModel } from './video' 11import { VideoModel } from './video'
12import * as Sequelize from 'sequelize'
12 13
13@Table({ 14@Table({
14 tableName: 'videoFile', 15 tableName: 'videoFile',
@@ -68,4 +69,18 @@ export class VideoFileModel extends Model<VideoFileModel> {
68 onDelete: 'CASCADE' 69 onDelete: 'CASCADE'
69 }) 70 })
70 Video: VideoModel 71 Video: VideoModel
72
73 static isInfohashExists (infoHash: string) {
74 const query = 'SELECT 1 FROM "videoFile" WHERE "infoHash" = $infoHash LIMIT 1'
75 const options = {
76 type: Sequelize.QueryTypes.SELECT,
77 bind: { infoHash },
78 raw: true
79 }
80
81 return VideoModel.sequelize.query(query, options)
82 .then(results => {
83 return results.length === 1
84 })
85 }
71} 86}