From a1d93180668a265d5f7bc595e8e864db10e356b6 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 1 Sep 2023 13:16:27 +0200 Subject: [PATCH] Stop live before removing files --- server/server/models/video/video.ts | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/server/server/models/video/video.ts b/server/server/models/video/video.ts index a6383b7c7..44d0605cc 100644 --- a/server/server/models/video/video.ts +++ b/server/server/models/video/video.ts @@ -796,6 +796,20 @@ export class VideoModel extends Model>> { InternalEventEmitter.Instance.emit('video-deleted', { video }) } + @BeforeDestroy + static stopLiveIfNeeded (instance: VideoModel) { + if (!instance.isLive) return + + logger.info('Stopping live of video %s after video deletion.', instance.uuid) + + LiveManager.Instance.stopSessionOf(instance.uuid, null) + } + + @BeforeDestroy + static invalidateCache (instance: VideoModel) { + ModelCache.Instance.invalidateCache('video', instance.id) + } + @BeforeDestroy static async sendDelete (instance: MVideoAccountLight, options: { transaction: Transaction }) { if (!instance.isOwned()) return undefined @@ -848,20 +862,6 @@ export class VideoModel extends Model>> { return undefined } - @BeforeDestroy - static stopLiveIfNeeded (instance: VideoModel) { - if (!instance.isLive) return - - logger.info('Stopping live of video %s after video deletion.', instance.uuid) - - LiveManager.Instance.stopSessionOf(instance.uuid, null) - } - - @BeforeDestroy - static invalidateCache (instance: VideoModel) { - ModelCache.Instance.invalidateCache('video', instance.id) - } - @BeforeDestroy static async saveEssentialDataToAbuses (instance: VideoModel, options) { const tasks: Promise[] = []