]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
Fix redundancy with videos already duplicated with another instance
authorChocobozzz <me@florianbigard.com>
Mon, 1 Oct 2018 07:41:48 +0000 (09:41 +0200)
committerChocobozzz <me@florianbigard.com>
Mon, 1 Oct 2018 07:41:48 +0000 (09:41 +0200)
server/lib/schedulers/videos-redundancy-scheduler.ts
server/middlewares/validators/redundancy.ts
server/models/redundancy/video-redundancy.ts

index 06cfa1101d744132133f6a9cf67974f5950a6265..d324adfd03a5a36286cdd9240e3b7a6a8c34c146 100644 (file)
@@ -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)
 
index d91b475743c3576ab0f3050640fa1a6850c52a40..c72ab78b23fa2c253a83956a51ae4e8e6d37b89b 100644 (file)
@@ -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
 
index 791ba3137c9cad1c5f0bfd03ea790c372e8a217b..c23a9cc17f26417b57c8dd870ee9f6e3d3bfe99c 100644 (file)
@@ -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
       }
     }