From 7b6cf83e33c1cf9719f77338288b9145b8cdcf60 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 26 Aug 2021 10:00:12 +0200 Subject: [PATCH] Fix redundancy remove on host redundancy update --- server/controllers/api/server/redundancy.ts | 8 +++-- server/models/redundancy/video-redundancy.ts | 24 +++++++++++++-- server/tests/api/redundancy/redundancy.ts | 31 ++++++++++++++------ 3 files changed, 48 insertions(+), 15 deletions(-) diff --git a/server/controllers/api/server/redundancy.ts b/server/controllers/api/server/redundancy.ts index 99d1c762b..e36c8d2db 100644 --- a/server/controllers/api/server/redundancy.ts +++ b/server/controllers/api/server/redundancy.ts @@ -106,9 +106,11 @@ async function updateRedundancy (req: express.Request, res: express.Response) { await server.save() - // Async, could be long - removeRedundanciesOfServer(server.id) - .catch(err => logger.error('Cannot remove redundancy of %s.', server.host, { err })) + if (server.redundancyAllowed !== true) { + // Async, could be long + removeRedundanciesOfServer(server.id) + .catch(err => logger.error('Cannot remove redundancy of %s.', server.host, { err })) + } return res.status(HttpStatusCode.NO_CONTENT_204).end() } diff --git a/server/models/redundancy/video-redundancy.ts b/server/models/redundancy/video-redundancy.ts index d645be248..44c17f8e5 100644 --- a/server/models/redundancy/video-redundancy.ts +++ b/server/models/redundancy/video-redundancy.ts @@ -470,16 +470,34 @@ export class VideoRedundancyModel extends Model