This commit is contained in:
Manav Rathi
2024-07-02 13:25:25 +05:30
parent c27f4a64df
commit 9c377d9ced
6 changed files with 44 additions and 37 deletions

View File

@@ -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";

View File

@@ -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,

View File

@@ -3,7 +3,7 @@ import {
indexableFileIDs,
indexedAndIndexableCounts,
updateAssumingLocalFiles,
} from "@/new/photos/services/face/db";
} from "@/new/photos/services/ml/db";
import {
isBetaUser,
isInternalUser,

View File

@@ -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();
}
}

View File

@@ -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(

View File

@@ -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]
*