Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

x4

Manav Rathief3231380786
diff --git a/web/apps/cast/src/services/pair.ts b/web/apps/cast/src/services/pair.ts
index b5646698cc..287122c456 100644
--- a/web/apps/cast/src/services/pair.ts
+++ b/web/apps/cast/src/services/pair.ts
@@ -82,7 +82,8 @@ export const register = async (): Promise<Registration> => {
// Register keypair with museum to get a pairing code.
let pairingCode: string | undefined;
- // TODO: eslint has fixed this spurious warning, but we're not on the latest
+ // [TODO: spurious while(true) eslint warning].
+ // eslint has fixed this spurious warning, but we're not on the latest
// version yet, so add a disable.
// https://github.com/eslint/eslint/pull/18286
/* eslint-disable no-constant-condition */
diff --git a/web/packages/new/photos/services/ml/worker.ts b/web/packages/new/photos/services/ml/worker.ts
index 5de8c08390..ca5f112468 100644
--- a/web/packages/new/photos/services/ml/worker.ts
+++ b/web/packages/new/photos/services/ml/worker.ts
@@ -288,15 +288,34 @@ const indexNextBatch = async (
// Nothing to do.
if (items.length == 0) return false;
- // Index, keeping track if any of the items failed.
+ // Keep track if any of the items failed.
let allSuccess = true;
- for (const item of items) {
- try {
- await index(item, electron);
- } catch {
- allSuccess = false;
+
+ // Index up to 4 items simultaneously.
+ const tasks = new Array<Promise<void> | undefined>(4).fill(undefined);
+
+ let i = 0;
+ while (i < items.length) {
+ for (let j = 0; j < tasks.length; j++) {
+ if (!tasks[j]) {
+ tasks[j] = index(ensure(items[i++]), electron)
+ .then(() => {
+ tasks[j] = undefined;
+ })
+ .catch(() => {
+ allSuccess = false;
+ tasks[j] = undefined;
+ });
+ }
}
+
+ // Wait for at least one to complete (the other runners continue running
+ // even if one promise reaches the finish line).
+ await Promise.race(tasks);
+
+ // Let the main thread now we're doing something.
delegate?.workerDidProcessFile();
+
// Let us drain the microtask queue. This also gives a chance for other
// interactive tasks like `clipMatches` to run.
await wait(0);