π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Add ML sync diagnostics and contextual faceID assertions
Anand Baburajan24e147366ff2
diff --git a/web/packages/new/photos/services/ml/index.ts b/web/packages/new/photos/services/ml/index.tsindex d5c23bf421..732a79026f 100644--- a/web/packages/new/photos/services/ml/index.ts+++ b/web/packages/new/photos/services/ml/index.ts@@ -353,25 +353,49 @@ export const mlSync = async () => {if (!_state.isMLEnabled) return;if (_state.isSyncing) return;_state.isSyncing = true;+ const runID = `${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 8)}`;+ const syncStartTime = Date.now();+ log.info(`[ml-sync ${runID}] start`);++ try {+ if (_state.needsResetFailures) {+ // CAS. See documentation for retryIndexingFailures why swapping the+ // flag before performing the operation is fine.+ _state.needsResetFailures = false;+ const resetStartTime = Date.now();+ log.info(`[ml-sync ${runID}] resetting failed file statuses`);+ await resetFailedFileStatuses();+ log.info(+ `[ml-sync ${runID}] reset failed file statuses in ${Date.now() - resetStartTime} ms`,+ );+ }- if (_state.needsResetFailures) {- // CAS. See documentation for retryIndexingFailures why swapping the- // flag before performing the operation is fine.- _state.needsResetFailures = false;- await resetFailedFileStatuses();- }-- // Dependency order for the sync- //- // files -> faces -> cgroups -> clusters -> people- //-- // Fetch indexes, or index locally if needed.- await worker().then((w) => w.index());-- await updateClustersAndPeople();+ // Dependency order for the sync+ //+ // files -> faces -> cgroups -> clusters -> people+ //++ // Fetch indexes, or index locally if needed.+ const indexStartTime = Date.now();+ log.info(`[ml-sync ${runID}] indexing start`);+ await worker().then((w) => w.index());+ log.info(+ `[ml-sync ${runID}] indexing done in ${Date.now() - indexStartTime} ms`,+ );- _state.isSyncing = false;+ const clusterAndPeopleStartTime = Date.now();+ log.info(`[ml-sync ${runID}] cluster+people update start`);+ await updateClustersAndPeople();+ log.info(+ `[ml-sync ${runID}] cluster+people update done in ${Date.now() - clusterAndPeopleStartTime} ms`,+ );+ } catch (e) {+ log.error(`[ml-sync ${runID}] failed`, e);+ throw e;+ } finally {+ _state.isSyncing = false;+ log.info(`[ml-sync ${runID}] end (${Date.now() - syncStartTime} ms)`);+ }};const updateClustersAndPeople = async () => {diff --git a/web/packages/new/photos/services/ml/people.ts b/web/packages/new/photos/services/ml/people.tsindex db698065bf..3a608fa676 100644--- a/web/packages/new/photos/services/ml/people.ts+++ b/web/packages/new/photos/services/ml/people.ts@@ -575,7 +575,9 @@ export const _suggestionsAndChoicesForPerson = async (for (const faceID of cluster.faces) {const fileID = fileIDFromFaceID(faceID);if (!fileID) {- assertionFailed();+ assertionFailed(+ `Invalid faceID while preparing preview faces: personID=${person.id}, clusterID=${cluster.id}, faceID=${faceID}, fileID=${String(fileID)}`,+ );continue;}