Skip to content

armgit / ente

Public Imported from GitHub
0

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

Filter instead of marking as errors

Manav Rathiac8677d7b4f0
diff --git a/web/apps/photos/src/services/face/db.ts b/web/apps/photos/src/services/face/db.ts
index bfa54e7d6a..fe5a93cdb2 100644
--- a/web/apps/photos/src/services/face/db.ts
+++ b/web/apps/photos/src/services/face/db.ts
@@ -198,10 +198,12 @@ export const addFileEntry = async (fileID: number) => {
};
/**
- * Sync entries in the face DB to match the given list of local file IDs.
+ * Sync entries in the face DB to align with the given list of local indexable
+ * file IDs.
*
* @param localFileIDs The IDs of all the files that the client is aware of,
- * filtered to only keep the files that the user owns.
+ * filtered to only keep the files that the user owns and the formats that can
+ * be indexed by our current face indexing pipeline.
*
* This function syncs the state of file entries in face DB to the state of file
* entries stored otherwise by the local client.
@@ -212,7 +214,7 @@ export const addFileEntry = async (fileID: number) => {
* - Files that are not present locally but still exist in face DB are removed
* from face DB (including its face index, if any).
*/
-export const syncWithLocalUserOwnedFileIDs = async (localFileIDs: number[]) => {
+export const syncWithLocalIndexableFileIDs = async (localFileIDs: number[]) => {
const db = await faceDB();
const tx = db.transaction(["face-index", "file-status"], "readwrite");
const fdbFileIDs = await tx.objectStore("file-status").getAllKeys();
diff --git a/web/apps/photos/src/services/face/f-index.ts b/web/apps/photos/src/services/face/f-index.ts
index d2c5579a2f..fa9fdea86a 100644
--- a/web/apps/photos/src/services/face/f-index.ts
+++ b/web/apps/photos/src/services/face/f-index.ts
@@ -93,6 +93,7 @@ const fetchRenderableBlob = async (enteFile: EnteFile) => {
);
return getRenderableImage(imageFileName, new Blob([imageData]));
} else {
+ // A layer above us should've already filtered these out.
throw new Error(`Cannot index unsupported file type ${fileType}`);
}
};
diff --git a/web/apps/photos/src/services/face/indexer.ts b/web/apps/photos/src/services/face/indexer.ts
index 9f3cc4a9d3..c880de2ef2 100644
--- a/web/apps/photos/src/services/face/indexer.ts
+++ b/web/apps/photos/src/services/face/indexer.ts
@@ -1,3 +1,4 @@
+import { FILE_TYPE } from "@/media/file-type";
import log from "@/next/log";
import { ComlinkWorker } from "@/next/worker/comlink-worker";
import { wait } from "@/utils/promise";
@@ -245,7 +246,7 @@ export const setIsFaceIndexingEnabled = async (enabled: boolean) => {
};
export const syncLocalFiles = async (userID: number) => {
- const localFilesMap = await localUserOwnedFilesByID(userID);
+ const localFilesMap = await localIndexableFilesByID(userID);
// const localFileIDs = new Set(localFilesMap.keys());
@@ -306,12 +307,17 @@ export const syncLocalFiles = async (userID: number) => {
*
* @param userID Restrict the returned files to those owned by a {@link userID}.
*/
-const localUserOwnedFilesByID = async (
+const localIndexableFilesByID = async (
userID: number,
): Promise<Map<number, EnteFile>> => {
const result = new Map<number, EnteFile>();
const localFiles = await getLocalFiles();
- const personalFiles = localFiles.filter((f) => f.ownerID === userID);
- personalFiles.forEach((f) => result.set(f.id, f));
+ const indexableTypes = [FILE_TYPE.IMAGE, FILE_TYPE.LIVE_PHOTO];
+ const indexableFiles = localFiles.filter(
+ (f) =>
+ f.ownerID == userID && indexableTypes.includes(f.metadata.fileType),
+ );
+
+ indexableFiles.forEach((f) => result.set(f.id, f));
return result;
};