From d96d4773cfee137aa47255058f479948905f149d Mon Sep 17 00:00:00 2001 From: Manav Rathi Date: Mon, 19 Aug 2024 14:42:46 +0530 Subject: [PATCH] Fix status during live uploads --- web/packages/new/photos/services/ml/index.ts | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/web/packages/new/photos/services/ml/index.ts b/web/packages/new/photos/services/ml/index.ts index e4c56a4569..53a57a3b73 100644 --- a/web/packages/new/photos/services/ml/index.ts +++ b/web/packages/new/photos/services/ml/index.ts @@ -479,13 +479,19 @@ const getMLStatus = async (): Promise => { const { indexedCount, indexableCount } = await indexableAndIndexedCounts(); + // During live uploads, the indexable count remains zero even as the indexer + // is processing the newly uploaded items. This is because these "live + // queue" items do not yet have a "file-status" entry. + // + // So use the state of the worker as a guide for the phase, not the + // indexable count. + let phase: MLStatus["phase"]; - if (indexableCount > 0) { - const state = await (await worker()).state; - phase = - state == "indexing" || state == "fetching" ? state : "scheduled"; + const state = await (await worker()).state; + if (state == "indexing" || state == "fetching") { + phase = state; } else { - phase = "done"; + phase = indexableCount > 0 ? "scheduled" : "done"; } return {