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 } }