From 161b061d4e51eb1e2b2b7e9482d5299489ef7c45 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 28 Sep 2018 10:07:05 +0200 Subject: Remove duplicated videos on unfollow/delete redundancy --- server/lib/redundancy.ts | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'server/lib/redundancy.ts') diff --git a/server/lib/redundancy.ts b/server/lib/redundancy.ts index 16b122658..04d3ded8f 100644 --- a/server/lib/redundancy.ts +++ b/server/lib/redundancy.ts @@ -12,8 +12,17 @@ async function removeVideoRedundancy (videoRedundancy: VideoRedundancyModel, t?: await videoRedundancy.destroy({ transaction: t }) } +async function removeRedundancyOf (serverId: number) { + const videosRedundancy = await VideoRedundancyModel.listLocalOfServer(serverId) + + for (const redundancy of videosRedundancy) { + await removeVideoRedundancy(redundancy) + } +} + // --------------------------------------------------------------------------- export { + removeRedundancyOf, removeVideoRedundancy } -- cgit v1.2.3