π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Add remove
Manav Rathi6b1484671bf9
diff --git a/web/apps/photos/src/services/face/db.ts b/web/apps/photos/src/services/face/db.tsindex 85bb322056..1625376a79 100644--- a/web/apps/photos/src/services/face/db.ts+++ b/web/apps/photos/src/services/face/db.ts@@ -197,18 +197,36 @@ export const addFileEntry = async (fileID: number) => {return tx.done;};+/**+ * Remove a file's entry and face index (if any) from the face DB.+ *+ * @param fileID The ID of an {@link EnteFile}+ *+ * This function is invoked when the user has deleted a file, and we want to+ * also prune that file's data from the face DB.+ */+export const removeFile = async (fileID: number) => {+ const db = await faceDB();+ const tx = db.transaction(["face-index", "file-status"], "readwrite");+ return Promise.all([+ tx.objectStore("face-index").delete(fileID),+ tx.objectStore("file-status").delete(fileID),+ tx.done,+ ]);+};+/*** Return the count of files that can be, and that have been, indexed.*/-export const indexableAndIndexedCounts = async () => {+export const indexedAndIndexableCounts = async () => {const db = await faceDB();- const tx = db.transaction(["file-status", "face-index"], "readonly");+ const tx = db.transaction(["face-index", "file-status"], "readwrite");+ const indexedCount = await tx.objectStore("face-index").count();const indexableCount = await tx.objectStore("file-status").index("isIndexable").count(IDBKeyRange.only(1));- const indexedCount = await tx.objectStore("face-index").count();- return { indexableCount, indexedCount };+ return { indexedCount, indexableCount };};/**diff --git a/web/apps/photos/src/services/face/indexer.ts b/web/apps/photos/src/services/face/indexer.tsindex 98a22b3e1e..a10ff34bb1 100644--- a/web/apps/photos/src/services/face/indexer.ts+++ b/web/apps/photos/src/services/face/indexer.ts@@ -10,7 +10,7 @@ import machineLearningService, {import mlWorkManager from "services/machineLearning/mlWorkManager";import type { EnteFile } from "types/file";import { isInternalUserForML } from "utils/user";-import { indexableAndIndexedCounts, markIndexingFailed } from "./db";+import { indexedAndIndexableCounts, markIndexingFailed } from "./db";import type { IndexStatus, MinimalPersistedFileData } from "./db-old";import { indexFaces } from "./f-index";import { FaceIndexerWorker } from "./indexer.worker";@@ -161,7 +161,7 @@ export interface FaceIndexingStatus {export const faceIndexingStatus = async (): Promise<FaceIndexingStatus> => {const isSyncing = machineLearningService.isSyncing;- const { indexableCount, indexedCount } = await indexableAndIndexedCounts();+ const { indexedCount, indexableCount } = await indexedAndIndexableCounts();let phase: FaceIndexingStatus["phase"];if (indexedCount < indexableCount) {@@ -176,8 +176,8 @@ export const faceIndexingStatus = async (): Promise<FaceIndexingStatus> => {const indexingStatus = {phase,- nTotalFiles: indexableCount,nSyncedFiles: indexedCount,+ nTotalFiles: indexableCount,};const indexStatus0 = await mlIDbStorage.getIndexStatus(defaultMLVersion);