diff --git a/web/apps/photos/src/services/face/db.ts b/web/apps/photos/src/services/face/db.ts index 797806a154..79f5fe54e1 100644 --- a/web/apps/photos/src/services/face/db.ts +++ b/web/apps/photos/src/services/face/db.ts @@ -269,10 +269,12 @@ export const syncWithLocalFiles = async ( const normal = new Set(indexableNormalFilesByID.keys()); const hidden = new Set(indexableHiddenFilesByID.keys()); + const all = new Set([...normal, ...hidden]); const fdb = new Set(fdbFileIDs); + const localFileIDs = [...all]; const newFileIDs = localFileIDs.filter((id) => !fdb.has(id)); - const removedFileIDs = fdbFileIDs.filter((id) => !local.has(id)); + const removedFileIDs = fdbFileIDs.filter((id) => !all.has(id)); return Promise.all( [ @@ -280,6 +282,7 @@ export const syncWithLocalFiles = async ( tx.objectStore("file-status").put({ fileID: id, status: "indexable", + isHidden: hidden.has(id) ? 1 : 0, failureCount: 0, }), ), diff --git a/web/apps/photos/src/services/face/f-index.ts b/web/apps/photos/src/services/face/f-index.ts index 79a428d0bc..7a61b55b1e 100644 --- a/web/apps/photos/src/services/face/f-index.ts +++ b/web/apps/photos/src/services/face/f-index.ts @@ -45,8 +45,7 @@ import type { Box, Dimensions, Face, Point } from "./types"; * available. These are used when they are provided, otherwise the file is * downloaded and decrypted from remote. * - * @param userAgent The UA of the current client (the client that is generating - * the embedding). + * @param userAgent The UA of the client that is doing the indexing (us). */ export const indexFaces = async ( enteFile: EnteFile, diff --git a/web/apps/photos/src/services/face/indexer.worker.ts b/web/apps/photos/src/services/face/indexer.worker.ts index 969a800295..a1a457b5cb 100644 --- a/web/apps/photos/src/services/face/indexer.worker.ts +++ b/web/apps/photos/src/services/face/indexer.worker.ts @@ -20,7 +20,7 @@ import type { FaceIndex } from "./types"; * comlink workers are structured. */ export class FaceIndexerWorker { - /* + /** * Index faces in a file, save the persist the results locally, and put them * on remote. * @@ -31,8 +31,18 @@ export class FaceIndexerWorker { * 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. + * + * @param isHidden `true` if the file we're trying to index is currently + * hidden. + * + * @param userAgent The UA of the client that is doing the indexing (us). */ - async index(enteFile: EnteFile, file: File | undefined, userAgent: string) { + async index( + enteFile: EnteFile, + file: File | undefined, + isHidden: boolean, + userAgent: string, + ) { const f = fileLogID(enteFile); const startTime = Date.now(); @@ -44,13 +54,13 @@ export class FaceIndexerWorker { // failed, not if there were subsequent failures (like when trying // to put the result to remote or save it to the local face DB). log.error(`Failed to index faces in ${f}`, e); - markIndexingFailed(enteFile.id); + markIndexingFailed(enteFile.id, isHidden); throw e; } try { await putFaceIndex(enteFile, faceIndex); - await saveFaceIndex(faceIndex); + await saveFaceIndex(faceIndex, isHidden); } catch (e) { log.error(`Failed to put/save face index for ${f}`, e); throw e;