]>
Commit | Line | Data |
---|---|---|
c48e82b5 C |
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' | |
453e83ea | 5 | import { MVideoRedundancyVideo } from '@server/typings/models' |
c48e82b5 | 6 | |
453e83ea | 7 | async function removeVideoRedundancy (videoRedundancy: MVideoRedundancyVideo, t?: Transaction) { |
c48e82b5 C |
8 | const serverActor = await getServerActor() |
9 | ||
e5565833 C |
10 | // Local cache, send undo to remote instances |
11 | if (videoRedundancy.actorId === serverActor.id) await sendUndoCacheFile(serverActor, videoRedundancy, t) | |
c48e82b5 C |
12 | |
13 | await videoRedundancy.destroy({ transaction: t }) | |
14 | } | |
15 | ||
b764380a C |
16 | async function removeRedundanciesOfServer (serverId: number) { |
17 | const redundancies = await VideoRedundancyModel.listLocalOfServer(serverId) | |
161b061d | 18 | |
b764380a | 19 | for (const redundancy of redundancies) { |
161b061d C |
20 | await removeVideoRedundancy(redundancy) |
21 | } | |
22 | } | |
23 | ||
c48e82b5 C |
24 | // --------------------------------------------------------------------------- |
25 | ||
26 | export { | |
b764380a | 27 | removeRedundanciesOfServer, |
c48e82b5 C |
28 | removeVideoRedundancy |
29 | } |