π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
ll
Manav Rathi4ce02fba93bb
diff --git a/web/apps/photos/src/services/face/f-index.ts b/web/apps/photos/src/services/face/f-index.tsindex 5e93f60bd6..a1a614f138 100644--- a/web/apps/photos/src/services/face/f-index.ts+++ b/web/apps/photos/src/services/face/f-index.ts@@ -12,6 +12,7 @@ import {translate,} from "transformation-matrix";import type { EnteFile } from "types/file";+import { logIdentifier } from "utils/file";import { saveFaceCrop } from "./crop";import { fetchImageBitmap, getLocalFileImageBitmap } from "./file";import {@@ -58,7 +59,7 @@ export const indexFaces = async (enteFile: EnteFile, localFile?: File) => {log.debug(() => {const nf = mlFile.faces?.length ?? 0;const ms = Date.now() - startTime;- return `Indexed ${nf} faces in file ${enteFile.id} (${ms} ms)`;+ return `Indexed ${nf} faces in file ${logIdentifier(enteFile)} (${ms} ms)`;});return mlFile;};diff --git a/web/apps/photos/src/services/face/indexer.worker.ts b/web/apps/photos/src/services/face/indexer.worker.tsindex 61c62b4029..84250dd703 100644--- a/web/apps/photos/src/services/face/indexer.worker.ts+++ b/web/apps/photos/src/services/face/indexer.worker.ts@@ -1,6 +1,7 @@import log from "@/next/log";import type { EnteFile } from "types/file";-import { markIndexingFailed } from "./db";+import { logIdentifier } from "utils/file";+import { closeFaceDBConnectionsIfNeeded, markIndexingFailed } from "./db";import { indexFaces } from "./f-index";/**@@ -13,14 +14,34 @@ import { indexFaces } from "./f-index";* comlink workers are structured.*/export class FaceIndexerWorker {+ /*+ * Index faces in a file, save the persist the results locally, and put them+ * on remote.+ *+ * @param enteFile The {@link EnteFile} to index.+ *+ * @param file If the file is one which is being uploaded from the current+ * client, then we will also have access to the file's content. In such+ * cases, pass a web {@link File} object to use that its data directly for+ * face indexing. If this is not provided, then the file's contents will be+ * downloaded and decrypted from remote.+ */async index(enteFile: EnteFile, file: File | undefined) {- const fileID = enteFile.id;+ const f = logIdentifier(enteFile);try {const faceIndex = await indexFaces(enteFile, file);- log.info(`faces in file ${fileID}`, faceIndex);+ log.info(`faces in file ${f}`, faceIndex);} catch (e) {- log.error(`Failed to index faces in file ${fileID}`, e);+ log.error(`Failed to index faces in file ${f}`, e);markIndexingFailed(enteFile.id);}}++ /**+ * Calls {@link closeFaceDBConnectionsIfNeeded} to close any open+ * connections to the face DB from the web worker's context.+ */+ closeFaceDB() {+ closeFaceDBConnectionsIfNeeded();+ }}diff --git a/web/apps/photos/src/utils/file/index.ts b/web/apps/photos/src/utils/file/index.tsindex 3a349abea7..c15cca63c0 100644--- a/web/apps/photos/src/utils/file/index.ts+++ b/web/apps/photos/src/utils/file/index.ts@@ -81,6 +81,14 @@ class ModuleState {const moduleState = new ModuleState();+/**+ * @returns a string to use as an identifier when logging information about the+ * given {@link enteFile}. The returned string contains the file name (for ease+ * of debugging) and the file ID (for exactness).+ */+export const logIdentifier = (enteFile: EnteFile) =>+ `${enteFile.metadata.title ?? "-"} (${enteFile.id})`;+export async function getUpdatedEXIFFileForDownload(fileReader: FileReader,file: EnteFile,