aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/redundancy/video-redundancy.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-10-03 16:43:57 +0200
committerChocobozzz <me@florianbigard.com>2018-10-03 16:43:57 +0200
commit25378bc866a69002d7447e5edc254ec7e469a1ec (patch)
treefd12d97cb571de83b1281554baba9c28606eaab9 /server/models/redundancy/video-redundancy.ts
parentbe691a57c590348fd36d6e11dc1fe4cc8eaa0719 (diff)
downloadPeerTube-25378bc866a69002d7447e5edc254ec7e469a1ec.tar.gz
PeerTube-25378bc866a69002d7447e5edc254ec7e469a1ec.tar.zst
PeerTube-25378bc866a69002d7447e5edc254ec7e469a1ec.zip
Delete correctly redundancy files
Diffstat (limited to 'server/models/redundancy/video-redundancy.ts')
-rw-r--r--server/models/redundancy/video-redundancy.ts12
1 files changed, 7 insertions, 5 deletions
diff --git a/server/models/redundancy/video-redundancy.ts b/server/models/redundancy/video-redundancy.ts
index c23a9cc17..da1c6f4a7 100644
--- a/server/models/redundancy/video-redundancy.ts
+++ b/server/models/redundancy/video-redundancy.ts
@@ -1,6 +1,6 @@
1import { 1import {
2 AfterDestroy,
3 AllowNull, 2 AllowNull,
3 BeforeDestroy,
4 BelongsTo, 4 BelongsTo,
5 Column, 5 Column,
6 CreatedAt, 6 CreatedAt,
@@ -115,14 +115,16 @@ export class VideoRedundancyModel extends Model<VideoRedundancyModel> {
115 }) 115 })
116 Actor: ActorModel 116 Actor: ActorModel
117 117
118 @AfterDestroy 118 @BeforeDestroy
119 static removeFile (instance: VideoRedundancyModel) { 119 static async removeFile (instance: VideoRedundancyModel) {
120 // Not us 120 // Not us
121 if (!instance.strategy) return 121 if (!instance.strategy) return
122 122
123 logger.info('Removing duplicated video file %s-%s.', instance.VideoFile.Video.uuid, instance.VideoFile.resolution) 123 const videoFile = await VideoFileModel.loadWithVideo(instance.videoFileId)
124 124
125 return instance.VideoFile.Video.removeFile(instance.VideoFile) 125 logger.info('Removing duplicated video file %s-%s.', videoFile.Video.uuid, videoFile.resolution)
126
127 return videoFile.Video.removeFile(videoFile)
126 } 128 }
127 129
128 static async loadLocalByFileId (videoFileId: number) { 130 static async loadLocalByFileId (videoFileId: number) {