X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fmodels%2Fredundancy%2Fvideo-redundancy.ts;h=c23a9cc17f26417b57c8dd870ee9f6e3d3bfe99c;hb=46f8d69b4e58a3006c32b2e0d97b9262fd30fd6b;hp=e6716480280c32f1ce89faf44f360f8fee62ee80;hpb=161b061d4e51eb1e2b2b7e9482d5299489ef7c45;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/models/redundancy/video-redundancy.ts b/server/models/redundancy/video-redundancy.ts index e67164802..c23a9cc17 100644 --- a/server/models/redundancy/video-redundancy.ts +++ b/server/models/redundancy/video-redundancy.ts @@ -125,9 +125,12 @@ export class VideoRedundancyModel extends Model { return instance.VideoFile.Video.removeFile(instance.VideoFile) } - static loadByFileId (videoFileId: number) { + static async loadLocalByFileId (videoFileId: number) { + const actor = await getServerActor() + const query = { where: { + actorId: actor.id, videoFileId } } @@ -146,6 +149,38 @@ export class VideoRedundancyModel extends Model { return VideoRedundancyModel.findOne(query) } + static async isLocalByVideoUUIDExists (uuid: string) { + const actor = await getServerActor() + + const query = { + raw: true, + attributes: [ 'id' ], + where: { + actorId: actor.id + }, + include: [ + { + attributes: [ ], + model: VideoFileModel, + required: true, + include: [ + { + attributes: [ ], + model: VideoModel, + required: true, + where: { + uuid + } + } + ] + } + ] + } + + return VideoRedundancyModel.findOne(query) + .then(r => !!r) + } + static async getVideoSample (p: Bluebird) { const rows = await p const ids = rows.map(r => r.id)