diff options
author | Chocobozzz <me@florianbigard.com> | 2023-09-01 13:16:27 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2023-09-01 13:16:27 +0200 |
commit | a1d93180668a265d5f7bc595e8e864db10e356b6 (patch) | |
tree | f3d9b405fc9085d26b406a2725e09b4f33b36350 /server | |
parent | d38a49463ffa994440d54561d8dc78263e3e0b6d (diff) | |
download | PeerTube-a1d93180668a265d5f7bc595e8e864db10e356b6.tar.gz PeerTube-a1d93180668a265d5f7bc595e8e864db10e356b6.tar.zst PeerTube-a1d93180668a265d5f7bc595e8e864db10e356b6.zip |
Stop live before removing files
Diffstat (limited to 'server')
-rw-r--r-- | server/server/models/video/video.ts | 28 |
1 files 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 | |||
@@ -797,6 +797,20 @@ export class VideoModel extends Model<Partial<AttributesOnly<VideoModel>>> { | |||
797 | } | 797 | } |
798 | 798 | ||
799 | @BeforeDestroy | 799 | @BeforeDestroy |
800 | static stopLiveIfNeeded (instance: VideoModel) { | ||
801 | if (!instance.isLive) return | ||
802 | |||
803 | logger.info('Stopping live of video %s after video deletion.', instance.uuid) | ||
804 | |||
805 | LiveManager.Instance.stopSessionOf(instance.uuid, null) | ||
806 | } | ||
807 | |||
808 | @BeforeDestroy | ||
809 | static invalidateCache (instance: VideoModel) { | ||
810 | ModelCache.Instance.invalidateCache('video', instance.id) | ||
811 | } | ||
812 | |||
813 | @BeforeDestroy | ||
800 | static async sendDelete (instance: MVideoAccountLight, options: { transaction: Transaction }) { | 814 | static async sendDelete (instance: MVideoAccountLight, options: { transaction: Transaction }) { |
801 | if (!instance.isOwned()) return undefined | 815 | if (!instance.isOwned()) return undefined |
802 | 816 | ||
@@ -849,20 +863,6 @@ export class VideoModel extends Model<Partial<AttributesOnly<VideoModel>>> { | |||
849 | } | 863 | } |
850 | 864 | ||
851 | @BeforeDestroy | 865 | @BeforeDestroy |
852 | static stopLiveIfNeeded (instance: VideoModel) { | ||
853 | if (!instance.isLive) return | ||
854 | |||
855 | logger.info('Stopping live of video %s after video deletion.', instance.uuid) | ||
856 | |||
857 | LiveManager.Instance.stopSessionOf(instance.uuid, null) | ||
858 | } | ||
859 | |||
860 | @BeforeDestroy | ||
861 | static invalidateCache (instance: VideoModel) { | ||
862 | ModelCache.Instance.invalidateCache('video', instance.id) | ||
863 | } | ||
864 | |||
865 | @BeforeDestroy | ||
866 | static async saveEssentialDataToAbuses (instance: VideoModel, options) { | 866 | static async saveEssentialDataToAbuses (instance: VideoModel, options) { |
867 | const tasks: Promise<any>[] = [] | 867 | const tasks: Promise<any>[] = [] |
868 | 868 | ||