diff options
author | Chocobozzz <me@florianbigard.com> | 2018-10-01 09:41:48 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-10-01 09:41:48 +0200 |
commit | 46f8d69b4e58a3006c32b2e0d97b9262fd30fd6b (patch) | |
tree | 8b06bd5f60d464723769fb53fe4f96558f3bfa74 /server | |
parent | 8b917537af2217ad0c87d49fd2ffa693d46a499c (diff) | |
download | PeerTube-46f8d69b4e58a3006c32b2e0d97b9262fd30fd6b.tar.gz PeerTube-46f8d69b4e58a3006c32b2e0d97b9262fd30fd6b.tar.zst PeerTube-46f8d69b4e58a3006c32b2e0d97b9262fd30fd6b.zip |
Fix redundancy with videos already duplicated with another instance
Diffstat (limited to 'server')
-rw-r--r-- | server/lib/schedulers/videos-redundancy-scheduler.ts | 2 | ||||
-rw-r--r-- | server/middlewares/validators/redundancy.ts | 2 | ||||
-rw-r--r-- | server/models/redundancy/video-redundancy.ts | 5 |
3 files changed, 6 insertions, 3 deletions
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 { | |||
109 | const serverActor = await getServerActor() | 109 | const serverActor = await getServerActor() |
110 | 110 | ||
111 | for (const file of filesToDuplicate) { | 111 | for (const file of filesToDuplicate) { |
112 | const existing = await VideoRedundancyModel.loadByFileId(file.id) | 112 | const existing = await VideoRedundancyModel.loadLocalByFileId(file.id) |
113 | if (existing) { | 113 | if (existing) { |
114 | await this.extendsExpirationOf(existing, redundancy.minLifetime) | 114 | await this.extendsExpirationOf(existing, redundancy.minLifetime) |
115 | 115 | ||
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 = [ | |||
37 | if (!videoFile) return res.status(404).json({ error: 'Video file not found.' }) | 37 | if (!videoFile) return res.status(404).json({ error: 'Video file not found.' }) |
38 | res.locals.videoFile = videoFile | 38 | res.locals.videoFile = videoFile |
39 | 39 | ||
40 | const videoRedundancy = await VideoRedundancyModel.loadByFileId(videoFile.id) | 40 | const videoRedundancy = await VideoRedundancyModel.loadLocalByFileId(videoFile.id) |
41 | if (!videoRedundancy)return res.status(404).json({ error: 'Video redundancy not found.' }) | 41 | if (!videoRedundancy)return res.status(404).json({ error: 'Video redundancy not found.' }) |
42 | res.locals.videoRedundancy = videoRedundancy | 42 | res.locals.videoRedundancy = videoRedundancy |
43 | 43 | ||
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<VideoRedundancyModel> { | |||
125 | return instance.VideoFile.Video.removeFile(instance.VideoFile) | 125 | return instance.VideoFile.Video.removeFile(instance.VideoFile) |
126 | } | 126 | } |
127 | 127 | ||
128 | static loadByFileId (videoFileId: number) { | 128 | static async loadLocalByFileId (videoFileId: number) { |
129 | const actor = await getServerActor() | ||
130 | |||
129 | const query = { | 131 | const query = { |
130 | where: { | 132 | where: { |
133 | actorId: actor.id, | ||
131 | videoFileId | 134 | videoFileId |
132 | } | 135 | } |
133 | } | 136 | } |