Pick from correct execution context

This commit is contained in:
Manav Rathi
2024-05-31 09:33:17 +05:30
parent c0c4412b19
commit c70c498d38
3 changed files with 6 additions and 6 deletions

View File

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

View File

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

View File

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