π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
test harness
Manav Rathi7bde0dea8ca1
diff --git a/web/apps/photos/src/services/entityService.ts b/web/apps/photos/src/services/entityService.tsindex 1aeba5ff44..be8a1e3a7f 100644--- a/web/apps/photos/src/services/entityService.ts+++ b/web/apps/photos/src/services/entityService.ts@@ -71,7 +71,8 @@ const getCachedEntityKey = async (type: EntityType) => {return entityKey;};-const getEntityKey = async (type: EntityType) => {+// TODO: unexport+export const getEntityKey = async (type: EntityType) => {try {const entityKey = await getCachedEntityKey(type);if (entityKey) {diff --git a/web/apps/photos/src/services/searchService.ts b/web/apps/photos/src/services/searchService.tsindex c697c34575..2bb7d304cb 100644--- a/web/apps/photos/src/services/searchService.ts+++ b/web/apps/photos/src/services/searchService.ts@@ -7,8 +7,10 @@ import {isMLSupported,mlStatusSnapshot,wipCluster,+ wipClusterEnable,} from "@/new/photos/services/ml";import type { Person } from "@/new/photos/services/ml/people";+import { personDiff } from "@/new/photos/services/user-entity";import { EnteFile } from "@/new/photos/types/file";import * as chrono from "chrono-node";import { t } from "i18next";@@ -25,7 +27,7 @@ import {import ComlinkSearchWorker from "utils/comlink/ComlinkSearchWorker";import { getUniqueFiles } from "utils/file";import { getFormattedDate } from "utils/search";-import { getLatestEntities } from "./entityService";+import { getEntityKey, getLatestEntities } from "./entityService";import locationSearchService, { City } from "./locationSearchService";const DIGITS = new Set(["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]);@@ -415,6 +417,15 @@ function convertSuggestionToSearchQuery(option: Suggestion): Search {}async function getAllPeople(limit: number = undefined) {+ if (!(await wipClusterEnable())) return [];++ const entityKey = await getEntityKey("person_v2" as EntityType);+ const peopleR = await personDiff(entityKey.data);+ const r = peopleR.length;+ log.debug(() => ["people", peopleR]);++ if (r) return [];+let people: Array<Person> = []; // await mlIDbStorage.getAllPeople();people = await wipCluster();// await mlPeopleStore.iterate<Person, void>((person) => {@@ -425,5 +436,6 @@ async function getAllPeople(limit: number = undefined) {.sort((p1, p2) => p2.files.length - p1.files.length).slice(0, limit);// log.debug(() => ["getAllPeople", result]);+return result;}diff --git a/web/packages/new/photos/services/ml/index.ts b/web/packages/new/photos/services/ml/index.tsindex bee9291563..7f44fa2010 100644--- a/web/packages/new/photos/services/ml/index.ts+++ b/web/packages/new/photos/services/ml/index.ts@@ -314,9 +314,15 @@ let last: Person[] | undefined;/*** WIP! Don't enable, dragon eggs are hatching here.*/+export const wipClusterEnable = async () => {+ if (!isDevBuild || !(await isInternalUser())) return false;+ if (!process.env.NEXT_PUBLIC_ENTE_WIP_CL) return false;+ if (last) return false;+ return true;+};+export const wipCluster = async () => {- if (!isDevBuild || !(await isInternalUser())) return;- if (!process.env.NEXT_PUBLIC_ENTE_WIP_CL) return;+ if (!(await wipClusterEnable())) return;if (last) return last;diff --git a/web/packages/new/photos/services/user-entity.ts b/web/packages/new/photos/services/user-entity.tsindex 939ed9d4e9..e7b08b822e 100644--- a/web/packages/new/photos/services/user-entity.ts+++ b/web/packages/new/photos/services/user-entity.ts@@ -2,6 +2,7 @@ import { decryptMetadataBytes } from "@/base/crypto/ente";import { authenticatedRequestHeaders, ensureOk } from "@/base/http";import { apiURL } from "@/base/origins";import { z } from "zod";+import { gunzip } from "./gzip";/*** User entities are predefined lists of otherwise arbitrary data that the user@@ -117,3 +118,17 @@ export const userEntityDiff = async (),);};++/**+ * Fetch all Person entities that have been created or updated since the last+ * time we checked.+ */+export const personDiff = async (entityKeyB64: string) => {+ const entities = await userEntityDiff("person_v2", 0, entityKeyB64);+ return Promise.all(+ entities.map(async ({ data }) => {+ if (!data) return undefined;+ return JSON.parse(await gunzip(data)) as unknown;+ }),+ );+};