X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;ds=sidebyside;f=server%2Fmodels%2Fredundancy%2Fvideo-redundancy.ts;h=da1c6f4a7f11d844e5047049e44aecdffd538f10;hb=25378bc866a69002d7447e5edc254ec7e469a1ec;hp=c23a9cc17f26417b57c8dd870ee9f6e3d3bfe99c;hpb=be691a57c590348fd36d6e11dc1fe4cc8eaa0719;p=github%2FChocobozzz%2FPeerTube.git 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 @@ import { - AfterDestroy, AllowNull, + BeforeDestroy, BelongsTo, Column, CreatedAt, @@ -115,14 +115,16 @@ export class VideoRedundancyModel extends Model { }) Actor: ActorModel - @AfterDestroy - static removeFile (instance: VideoRedundancyModel) { + @BeforeDestroy + static async removeFile (instance: VideoRedundancyModel) { // Not us if (!instance.strategy) return - logger.info('Removing duplicated video file %s-%s.', instance.VideoFile.Video.uuid, instance.VideoFile.resolution) + const videoFile = await VideoFileModel.loadWithVideo(instance.videoFileId) - return instance.VideoFile.Video.removeFile(instance.VideoFile) + logger.info('Removing duplicated video file %s-%s.', videoFile.Video.uuid, videoFile.resolution) + + return videoFile.Video.removeFile(videoFile) } static async loadLocalByFileId (videoFileId: number) {