From 9c377d9ced9ae6a09bb08405af5331d695139cd8 Mon Sep 17 00:00:00 2001 From: Manav Rathi Date: Tue, 2 Jul 2024 13:25:25 +0530 Subject: [PATCH] fix --- web/apps/photos/src/services/logout.ts | 4 +- web/apps/photos/src/utils/file/index.ts | 8 --- .../new/photos/services/ml/indexer.ts | 2 +- .../new/photos/services/ml/indexer.worker.ts | 8 +-- .../services/ml/machineLearningService.ts | 49 ++++++++++--------- web/packages/new/photos/utils/file.ts | 10 ++++ 6 files changed, 44 insertions(+), 37 deletions(-) diff --git a/web/apps/photos/src/services/logout.ts b/web/apps/photos/src/services/logout.ts index a58dd3e4d0..3f0736457d 100644 --- a/web/apps/photos/src/services/logout.ts +++ b/web/apps/photos/src/services/logout.ts @@ -1,6 +1,6 @@ import DownloadManager from "@/new/photos/services/download"; -import { terminateFaceWorker } from "@/new/photos/services/face"; -import { clearFaceData } from "@/new/photos/services/face/db"; +import { terminateFaceWorker } from "@/new/photos/services/ml"; +import { clearFaceData } from "@/new/photos/services/ml/db"; import { clearFeatureFlagSessionState } from "@/new/photos/services/feature-flags"; import mlWorkManager from "@/new/photos/services/ml/mlWorkManager"; import log from "@/next/log"; diff --git a/web/apps/photos/src/utils/file/index.ts b/web/apps/photos/src/utils/file/index.ts index 6f2b3b89fb..5ae7ace527 100644 --- a/web/apps/photos/src/utils/file/index.ts +++ b/web/apps/photos/src/utils/file/index.ts @@ -49,14 +49,6 @@ export enum FILE_OPS_TYPE { DELETE_PERMANENTLY, } -/** - * @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 fileLogID = (enteFile: EnteFile) => - `file ${enteFile.metadata.title ?? "-"} (${enteFile.id})`; - export async function getUpdatedEXIFFileForDownload( fileReader: FileReader, file: EnteFile, diff --git a/web/packages/new/photos/services/ml/indexer.ts b/web/packages/new/photos/services/ml/indexer.ts index a7dfe319b9..a17e85b2df 100644 --- a/web/packages/new/photos/services/ml/indexer.ts +++ b/web/packages/new/photos/services/ml/indexer.ts @@ -3,7 +3,7 @@ import { indexableFileIDs, indexedAndIndexableCounts, updateAssumingLocalFiles, -} from "@/new/photos/services/face/db"; +} from "@/new/photos/services/ml/db"; import { isBetaUser, isInternalUser, diff --git a/web/packages/new/photos/services/ml/indexer.worker.ts b/web/packages/new/photos/services/ml/indexer.worker.ts index fdae17f2cc..c6184679fd 100644 --- a/web/packages/new/photos/services/ml/indexer.worker.ts +++ b/web/packages/new/photos/services/ml/indexer.worker.ts @@ -2,11 +2,11 @@ import { closeFaceDBConnectionsIfNeeded, markIndexingFailed, saveFaceIndex, -} from "@/new/photos/services/face/db"; +} from "@/new/photos/services/ml/db"; import type { FaceIndex } from "@/new/photos/services/ml/types"; import type { EnteFile } from "@/new/photos/types/file"; import log from "@/next/log"; -import { fileLogID } from "utils/file"; +import { fileLogID } from "../../utils/file"; import { indexFaces } from "./f-index"; import { putFaceIndex } from "./remote"; @@ -46,7 +46,7 @@ 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); + await markIndexingFailed(enteFile.id); throw e; } @@ -72,6 +72,6 @@ export class FaceIndexerWorker { * connections to the face DB from the web worker's context. */ closeFaceDB() { - closeFaceDBConnectionsIfNeeded(); + void closeFaceDBConnectionsIfNeeded(); } } diff --git a/web/packages/new/photos/services/ml/machineLearningService.ts b/web/packages/new/photos/services/ml/machineLearningService.ts index 74287c1f7a..cadd465b50 100644 --- a/web/packages/new/photos/services/ml/machineLearningService.ts +++ b/web/packages/new/photos/services/ml/machineLearningService.ts @@ -110,23 +110,23 @@ class MachineLearningService { return this.syncContext; } - private async getLocalSyncContext( - token: string, - userID: number, - userAgent: string, - ) { - // TODO-ML(MR): This is updating the file ML version. verify. - if (!this.localSyncContext) { - log.info("Creating localSyncContext"); - // TODO-ML(MR): - this.localSyncContext = new Promise((resolve) => { - resolve(new MLSyncContext(token, userID, userAgent)); - }); - } else { - log.info("reusing existing localSyncContext"); - } - return this.localSyncContext; - } + // private async getLocalSyncContext( + // token: string, + // userID: number, + // userAgent: string, + // ) { + // // TODO-ML(MR): This is updating the file ML version. verify. + // if (!this.localSyncContext) { + // log.info("Creating localSyncContext"); + // // TODO-ML(MR): + // this.localSyncContext = new Promise((resolve) => { + // resolve(new MLSyncContext(token, userID, userAgent)); + // }); + // } else { + // log.info("reusing existing localSyncContext"); + // } + // return this.localSyncContext; + // } public async closeLocalSyncContext() { if (this.localSyncContext) { @@ -139,15 +139,20 @@ class MachineLearningService { public async syncLocalFile( // eslint-disable-next-line @typescript-eslint/no-unused-vars - token: string, + _: string, + // token: string, // eslint-disable-next-line @typescript-eslint/no-unused-vars - userID: number, + __: number, + // userID: number, // eslint-disable-next-line @typescript-eslint/no-unused-vars - userAgent: string, + ___: string, + // userAgent: string, // eslint-disable-next-line @typescript-eslint/no-unused-vars - enteFile: EnteFile, + ____: EnteFile, + // enteFile: EnteFile, // eslint-disable-next-line @typescript-eslint/no-unused-vars - localFile?: globalThis.File, + _____?: globalThis.File, + // localFile?: globalThis.File, ) { /* TODO-ML(MR): Currently not used const syncContext = await this.getLocalSyncContext( diff --git a/web/packages/new/photos/utils/file.ts b/web/packages/new/photos/utils/file.ts index 92fb5dfff0..57c1087f70 100644 --- a/web/packages/new/photos/utils/file.ts +++ b/web/packages/new/photos/utils/file.ts @@ -23,6 +23,16 @@ 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 fileLogID = (enteFile: EnteFile) => + // TODO: Remove this when file/metadata types have optionality annotations. + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition + `file ${enteFile.metadata.title ?? "-"} (${enteFile.id})`; + /** * [Note: File name for local EnteFile objects] *