mirror of
https://github.com/fluxerapp/fluxer
synced 2026-10-17 13:05:32 +09:00
perf(worker): throttle the cancel check in the domain sync (#2207)
This commit is contained in:
1 parent
4357d5ec5d
commit
7aec79d3ad
1 file changed
+2
-2
@@ -176,20 +176,20 @@ const syncDisposableEmailDomains: WorkerTaskHandler = async (_payload, helpers)
|
|||||||
await helpers.reportProgress(0, totalOps, `Applying ${addCount} adds and ${removeCount} removes`);
|
await helpers.reportProgress(0, totalOps, `Applying ${addCount} adds and ${removeCount} removes`);
|
||||||
for (const domain of freshSet) {
|
for (const domain of freshSet) {
|
||||||
if (currentSet.has(domain)) continue;
|
if (currentSet.has(domain)) continue;
|
||||||
await throwIfCancelled(helpers);
|
|
||||||
await adminRepository.addDisposableEmailDomain(domain);
|
await adminRepository.addDisposableEmailDomain(domain);
|
||||||
added++;
|
added++;
|
||||||
if (added % WRITE_PROGRESS_INTERVAL === 0) {
|
if (added % WRITE_PROGRESS_INTERVAL === 0) {
|
||||||
await helpers.reportProgress(added + removed, totalOps, null);
|
await helpers.reportProgress(added + removed, totalOps, null);
|
||||||
|
await throwIfCancelled(helpers);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (const domain of currentSet) {
|
for (const domain of currentSet) {
|
||||||
if (freshSet.has(domain)) continue;
|
if (freshSet.has(domain)) continue;
|
||||||
await throwIfCancelled(helpers);
|
|
||||||
await adminRepository.removeDisposableEmailDomain(domain);
|
await adminRepository.removeDisposableEmailDomain(domain);
|
||||||
removed++;
|
removed++;
|
||||||
if (removed % WRITE_PROGRESS_INTERVAL === 0) {
|
if (removed % WRITE_PROGRESS_INTERVAL === 0) {
|
||||||
await helpers.reportProgress(added + removed, totalOps, null);
|
await helpers.reportProgress(added + removed, totalOps, null);
|
||||||
|
await throwIfCancelled(helpers);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
await helpers.reportProgress(totalOps, totalOps, `+${added} added, -${removed} removed`);
|
await helpers.reportProgress(totalOps, totalOps, `+${added} added, -${removed} removed`);
|
||||||
|
|||||||
Reference in new issue
Block a user