1 import { VideoRedundancyModel } from '../models/redundancy/video-redundancy'
2 import { sendUndoCacheFile } from './activitypub/send'
3 import { Transaction } from 'sequelize'
4 import { getServerActor } from '../helpers/utils'
5 import { MVideoRedundancyVideo } from '@server/typings/models'
7 async function removeVideoRedundancy (videoRedundancy: MVideoRedundancyVideo, t?: Transaction) {
8 const serverActor = await getServerActor()
10 // Local cache, send undo to remote instances
11 if (videoRedundancy.actorId === serverActor.id) await sendUndoCacheFile(serverActor, videoRedundancy, t)
13 await videoRedundancy.destroy({ transaction: t })
16 async function removeRedundancyOf (serverId: number) {
17 const videosRedundancy = await VideoRedundancyModel.listLocalOfServer(serverId)
19 for (const redundancy of videosRedundancy) {
20 await removeVideoRedundancy(redundancy)
24 // ---------------------------------------------------------------------------