Skip to content

armgit / ente

Public Imported from GitHub
0

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

Pick from correct execution context

Manav Rathic70c498d38ff
diff --git a/web/apps/photos/src/services/face/indexer.ts b/web/apps/photos/src/services/face/indexer.ts
index 98eaaa02ce..893ff0c863 100644
--- a/web/apps/photos/src/services/face/indexer.ts
+++ b/web/apps/photos/src/services/face/indexer.ts
@@ -4,7 +4,6 @@ import { ensure } from "@/utils/ensure";
import { wait } from "@/utils/promise";
import { type Remote } from "comlink";
import { getLocalFiles } from "services/fileService";
-import machineLearningService from "services/machineLearning/machineLearningService";
import mlWorkManager from "services/machineLearning/mlWorkManager";
import type { EnteFile } from "types/file";
import { isInternalUserForML } from "utils/user";
@@ -162,7 +161,7 @@ export interface FaceIndexingStatus {
}
export const faceIndexingStatus = async (): Promise<FaceIndexingStatus> => {
- const isSyncing = machineLearningService.isSyncing;
+ const isSyncing = mlWorkManager.isSyncing;
const { indexedCount, indexableCount } = await indexedAndIndexableCounts();
let phase: FaceIndexingStatus["phase"];
diff --git a/web/apps/photos/src/services/machineLearning/machineLearningService.ts b/web/apps/photos/src/services/machineLearning/machineLearningService.ts
index 8549ec7655..640644ada4 100644
--- a/web/apps/photos/src/services/machineLearning/machineLearningService.ts
+++ b/web/apps/photos/src/services/machineLearning/machineLearningService.ts
@@ -45,8 +45,6 @@ class MachineLearningService {
private localSyncContext: Promise<MLSyncContext>;
private syncContext: Promise<MLSyncContext>;
- public isSyncing = false;
-
public async sync(
token: string,
userID: number,
@@ -70,7 +68,6 @@ class MachineLearningService {
}
private async syncFiles(syncContext: MLSyncContext) {
- this.isSyncing = true;
try {
const functions = syncContext.outOfSyncFiles.map(
(outOfSyncfile) => async () => {
@@ -90,7 +87,6 @@ class MachineLearningService {
syncContext.error = error;
}
await syncContext.syncQueue.onIdle();
- this.isSyncing = false;
}
private async getSyncContext(
diff --git a/web/apps/photos/src/services/machineLearning/mlWorkManager.ts b/web/apps/photos/src/services/machineLearning/mlWorkManager.ts
index 9502c5a75d..867df8ef65 100644
--- a/web/apps/photos/src/services/machineLearning/mlWorkManager.ts
+++ b/web/apps/photos/src/services/machineLearning/mlWorkManager.ts
@@ -97,6 +97,8 @@ class MLWorkManager {
private liveSyncWorker: ComlinkWorker<typeof DedicatedMLWorker>;
private mlSearchEnabled: boolean;
+ public isSyncing = false;
+
constructor() {
this.liveSyncQueue = new PQueue({
concurrency: 1,
@@ -270,6 +272,7 @@ class MLWorkManager {
* things pending to process, so we should chug along at full speed.
*/
private async runMLSyncJob(): Promise<boolean> {
+ this.isSyncing = true;
try {
// TODO: skipping is not required if we are caching chunks through service worker
// currently worker chunk itself is not loaded when network is not there
@@ -290,6 +293,8 @@ class MLWorkManager {
// TODO: redirect/refresh to gallery in case of session_expired, stop ml sync job
} catch (e) {
log.error("Failed to run MLSync Job", e);
+ } finally {
+ this.isSyncing = false;
}
}