Skip to content

armgit / ente

Public Imported from GitHub
0

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

Outline

Manav Rathid9200f470363
diff --git a/web/apps/photos/src/services/face/indexer.ts b/web/apps/photos/src/services/face/indexer.ts
index c2188a3921..d14b8d484c 100644
--- a/web/apps/photos/src/services/face/indexer.ts
+++ b/web/apps/photos/src/services/face/indexer.ts
@@ -3,7 +3,9 @@ import { ComlinkWorker } from "@/next/worker/comlink-worker";
import { wait } from "@/utils/promise";
import { type Remote } from "comlink";
import mlIDbStorage from "services/face/db-old";
-import { defaultMLVersion } from "services/machineLearning/machineLearningService";
+import machineLearningService, {
+ defaultMLVersion,
+} from "services/machineLearning/machineLearningService";
import mlWorkManager from "services/machineLearning/mlWorkManager";
import type { EnteFile } from "types/file";
import { markIndexingFailed } from "./db";
@@ -156,8 +158,31 @@ export interface FaceIndexingStatus {
}
export const faceIndexingStatus = async (): Promise<FaceIndexingStatus> => {
+ const isSyncing = machineLearningService.isSyncing;
+ const [indexableCount, indexedCount] = [0, 0];
+
+ let phase: FaceIndexingStatus["phase"];
+ if (indexableCount > 0 && indexableCount > indexedCount) {
+ if (!isSyncing) {
+ phase = "scheduled";
+ } else {
+ phase = "indexing";
+ }
+ } else {
+ phase = "done";
+ }
+
+ const indexingStatus = {
+ phase,
+ nTotalFiles: indexableCount,
+ nSyncedFiles: indexedCount,
+ };
+
const indexStatus0 = await mlIDbStorage.getIndexStatus(defaultMLVersion);
const indexStatus = convertToNewInterface(indexStatus0);
+
+ log.debug(() => ({ indexStatus, indexingStatus }));
+
return indexStatus;
};
diff --git a/web/apps/photos/src/services/machineLearning/machineLearningService.ts b/web/apps/photos/src/services/machineLearning/machineLearningService.ts
index ef12c0891b..cbde414341 100644
--- a/web/apps/photos/src/services/machineLearning/machineLearningService.ts
+++ b/web/apps/photos/src/services/machineLearning/machineLearningService.ts
@@ -78,6 +78,8 @@ class MachineLearningService {
private localSyncContext: Promise<MLSyncContext>;
private syncContext: Promise<MLSyncContext>;
+ public isSyncing = false;
+
public async sync(
token: string,
userID: number,
@@ -192,6 +194,7 @@ class MachineLearningService {
}
private async syncFiles(syncContext: MLSyncContext) {
+ this.isSyncing = true;
try {
const functions = syncContext.outOfSyncFiles.map(
(outOfSyncfile) => async () => {
@@ -211,6 +214,7 @@ class MachineLearningService {
syncContext.error = error;
}
await syncContext.syncQueue.onIdle();
+ this.isSyncing = false;
// TODO: In case syncJob has to use multiple ml workers
// do in same transaction with each file update