Skip to content

ActivityPub-federated video streaming platform using P2P directly in your web browser

Fix redundancy with videos already duplicated with another instance

Chocobozzz46f8d69b4e58
diff --git a/server/lib/schedulers/videos-redundancy-scheduler.ts b/server/lib/schedulers/videos-redundancy-scheduler.ts
index 06cfa1101d..d324adfd03 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 d91b475743..c72ab78b23 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 791ba3137c..c23a9cc17f 100644
--- a/server/models/redundancy/video-redundancy.ts
+++ b/server/models/redundancy/video-redundancy.ts
@@ -125,9 +125,12 @@ export class VideoRedundancyModel extends Model<VideoRedundancyModel> {
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
}
}