π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Set cgroups
Manav Rathi212ab374ac53
diff --git a/web/apps/photos/src/services/sync.ts b/web/apps/photos/src/services/sync.tsindex af11377762..0f1e3ded1b 100644--- a/web/apps/photos/src/services/sync.ts+++ b/web/apps/photos/src/services/sync.ts@@ -3,8 +3,13 @@ import {isMLSupported,triggerMLStatusSync,triggerMLSync,+ wipClusterEnable,} from "@/new/photos/services/ml";-import { triggerSearchDataSync } from "@/new/photos/services/search";+import { syncCGroups } from "@/new/photos/services/ml/cgroups";+import {+ rereadCGroups,+ triggerSearchDataSync,+} from "@/new/photos/services/search";import { syncMapEnabled } from "services/userService";/**@@ -35,7 +40,13 @@ export const triggerPreFileInfoSync = () => {* before doing the file sync and thus should run immediately after login.*/export const sync = async () => {- await Promise.all([syncMapEnabled()]);+ await Promise.all([+ syncMapEnabled(),+ process.env.NEXT_PUBLIC_ENTE_WIP_CL &&+ wipClusterEnable().then((enable) =>+ enable ? syncCGroups().then(rereadCGroups) : undefined,+ ),+ ]);triggerSearchDataSync();if (isMLSupported) triggerMLSync();};diff --git a/web/packages/new/photos/services/search/index.ts b/web/packages/new/photos/services/search/index.tsindex 927e9ed8f0..0caa185eca 100644--- a/web/packages/new/photos/services/search/index.ts+++ b/web/packages/new/photos/services/search/index.ts@@ -4,6 +4,7 @@ import { ComlinkWorker } from "@/base/worker/comlink-worker";import { FileType } from "@/media/file-type";import i18n, { t } from "i18next";import { clipMatches, isMLEnabled, isMLSupported } from "../ml";+import { clusterGroups } from "../ml/db";import type {LabelledFileType,LabelledSearchDateComponents,@@ -57,6 +58,18 @@ export const setSearchableCollectionsAndFiles = (data: SearchableCollectionsAndFiles,) => void worker().then((w) => w.setSearchableCollectionsAndFiles(data));+/**+ * Re-read the cgroups across which we should search from the local ML DB.+ */+export const rereadCGroups = async () => {+ const w = await worker();+ // This DB read can happen in the search worker too, but that would cause+ // another handle to the DB to be opened (from the search worker's context).+ // Make the DB call here to avoid that (not that we noticed any issues, but+ // preemptively trying not to poke IndexedDB too much lest it be flaky).+ return w.setCGroups(await clusterGroups());+};+/*** Convert a search string into (annotated) suggestions that can be shown in the* search results dropdown.diff --git a/web/packages/new/photos/services/search/worker.ts b/web/packages/new/photos/services/search/worker.tsindex c0121c5cd6..2061014580 100644--- a/web/packages/new/photos/services/search/worker.ts+++ b/web/packages/new/photos/services/search/worker.ts@@ -1,4 +1,5 @@import { HTTPError } from "@/base/http";+import log from "@/base/log";import type { Location } from "@/base/types";import type { Collection } from "@/media/collection";import { fileCreationPhotoDate, fileLocation } from "@/media/file-metadata";@@ -77,7 +78,7 @@ export class SearchWorker {/*** Set the cgroups that we should search across.*/- setSearchableCGroups(cgroups: CGroup[]) {+ setCGroups(cgroups: CGroup[]) {this.searchableCGroups = cgroups.map((cgroup) => {const name = cgroup.name;@@ -86,6 +87,7 @@ export class SearchWorker {return { ...cgroup, name, lowercasedName: name.toLowerCase() };}).filter((c) => !!c);+ log.debug(() => ["searchableCGroups", this.searchableCGroups]);}/**