Skip to content

Commit

Permalink
IMAP: Throttle - Helps with #368
Browse files Browse the repository at this point in the history
  • Loading branch information
benbucksch committed Jan 10, 2025
1 parent f43fd53 commit 746dd4b
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions app/logic/Mail/IMAP/IMAPAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { ConnectError, LoginError } from "../../Abstract/Account";
import { SpecialFolder } from "../Folder";
import { assert, SpecificError } from "../../util/util";
import { Lock } from "../../util/Lock";
import { Throttle } from "../../util/Throttle";
import { sanitize } from "../../../../lib/util/sanitizeDatatypes";
import { appName, appVersion, siteRoot } from "../../build";
import { ArrayColl, MapColl, type Collection } from "svelte-collections";
Expand All @@ -22,6 +23,7 @@ export class IMAPAccount extends MailAccount {
pollIntervalMinutes = 10;
protected connections = new MapColl<ConnectionPurpose, ImapFlow>();
protected connectLock = new MapColl<ConnectionPurpose, Lock>();
throttle = new Throttle(50, 1);

constructor() {
super();
Expand Down Expand Up @@ -55,6 +57,7 @@ export class IMAPAccount extends MailAccount {
}

async connection(interactive = false, purpose = ConnectionPurpose.Main): Promise<ImapFlow> {
await this.throttle.throttle();
let conn = this.connections.get(purpose);
if (conn) {
return conn;
Expand Down

0 comments on commit 746dd4b

Please sign in to comment.