From 5ce1208a0a57d566b5b1fd57ec291a7d053ebaf0 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 28 Sep 2018 10:56:13 +0200 Subject: Improve prune script --- server/models/redundancy/video-redundancy.ts | 32 ++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'server') diff --git a/server/models/redundancy/video-redundancy.ts b/server/models/redundancy/video-redundancy.ts index e67164802..791ba3137 100644 --- a/server/models/redundancy/video-redundancy.ts +++ b/server/models/redundancy/video-redundancy.ts @@ -146,6 +146,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) -- cgit v1.2.3