From 46f8d69b4e58a3006c32b2e0d97b9262fd30fd6b Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 1 Oct 2018 09:41:48 +0200 Subject: Fix redundancy with videos already duplicated with another instance --- server/lib/schedulers/videos-redundancy-scheduler.ts | 2 +- server/middlewares/validators/redundancy.ts | 2 +- server/models/redundancy/video-redundancy.ts | 5 ++++- 3 files changed, 6 insertions(+), 3 deletions(-) (limited to 'server') diff --git a/server/lib/schedulers/videos-redundancy-scheduler.ts b/server/lib/schedulers/videos-redundancy-scheduler.ts index 06cfa1101..d324adfd0 100644 --- a/server/lib/schedulers/videos-redundancy-scheduler.ts +++ b/server/lib/schedulers/videos-redundancy-scheduler.ts @@ -109,7 +109,7 @@ export class VideosRedundancyScheduler extends AbstractScheduler { const serverActor = await getServerActor() for (const file of filesToDuplicate) { - const existing = await VideoRedundancyModel.loadByFileId(file.id) + const existing = await VideoRedundancyModel.loadLocalByFileId(file.id) if (existing) { await this.extendsExpirationOf(existing, redundancy.minLifetime) diff --git a/server/middlewares/validators/redundancy.ts b/server/middlewares/validators/redundancy.ts index d91b47574..c72ab78b2 100644 --- a/server/middlewares/validators/redundancy.ts +++ b/server/middlewares/validators/redundancy.ts @@ -37,7 +37,7 @@ const videoRedundancyGetValidator = [ if (!videoFile) return res.status(404).json({ error: 'Video file not found.' }) res.locals.videoFile = videoFile - const videoRedundancy = await VideoRedundancyModel.loadByFileId(videoFile.id) + const videoRedundancy = await VideoRedundancyModel.loadLocalByFileId(videoFile.id) if (!videoRedundancy)return res.status(404).json({ error: 'Video redundancy not found.' }) res.locals.videoRedundancy = videoRedundancy diff --git a/server/models/redundancy/video-redundancy.ts b/server/models/redundancy/video-redundancy.ts index 791ba3137..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 } } -- cgit v1.2.3