Skip to content

Commit

Permalink
Stop live before removing files
Browse files Browse the repository at this point in the history
  • Loading branch information
Chocobozzz committed Sep 1, 2023
1 parent d38a494 commit a1d9318
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions server/server/models/video/video.ts
Original file line number Diff line number Diff line change
Expand Up @@ -796,6 +796,20 @@ export class VideoModel extends Model<Partial<AttributesOnly<VideoModel>>> {
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
Expand Down Expand Up @@ -848,20 +862,6 @@ export class VideoModel extends Model<Partial<AttributesOnly<VideoModel>>> {
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<any>[] = []
Expand Down

0 comments on commit a1d9318

Please sign in to comment.