From 9c599d53aa74922fb3821b7ef2ecf6bf601ff1c1 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Mon, 31 Jan 2022 17:31:01 +0100 Subject: [PATCH] allow to inject max delay in key backup --- src/matrix/e2ee/megolm/keybackup/KeyBackup.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/matrix/e2ee/megolm/keybackup/KeyBackup.ts b/src/matrix/e2ee/megolm/keybackup/KeyBackup.ts index e97eb0cf..089d2b0a 100644 --- a/src/matrix/e2ee/megolm/keybackup/KeyBackup.ts +++ b/src/matrix/e2ee/megolm/keybackup/KeyBackup.ts @@ -51,6 +51,7 @@ export class KeyBackup { private readonly keyLoader: KeyLoader, private readonly storage: Storage, private readonly platform: Platform, + private readonly maxDelay: number = 10000 ) {} get hasStopped(): boolean { return this._stopped; } @@ -114,7 +115,7 @@ export class KeyBackup { let total = 0; let amountFinished = 0; while (true) { - const waitMs = this.platform.random() * 10000; + const waitMs = this.platform.random() * this.maxDelay; const timeout = this.platform.clock.createTimeout(waitMs); setAbortable(timeout); await timeout.elapsed();