π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Log at top level to cover unknown scenarios too
Manav Rathi802ad184d218
diff --git a/web/packages/base/log-web.ts b/web/packages/base/log-web.tsindex 85a66bb00e..6cfcba31cb 100644--- a/web/packages/base/log-web.ts+++ b/web/packages/base/log-web.ts@@ -56,6 +56,11 @@ export const logUnhandledErrorsAndRejections = (attach: boolean) => {** This is a variant of {@link logUnhandledErrorsAndRejections} that works in* web workers. It should be called at the top level of the main worker script.+ *+ * Note: When I tested this, attaching the onerror handler to the worker outside+ * the worker (e.g. when creating it in comlink-worker.ts) worked, but attaching+ * the "unhandledrejection" event there did not work. Attaching them to `self`+ * (the {@link WorkerGlobal}) worked.*/export const logUnhandledErrorsAndRejectionsInWorker = () => {const handleError = (event: ErrorEvent) => {diff --git a/web/packages/new/photos/services/ml/worker.ts b/web/packages/new/photos/services/ml/worker.tsindex e51defd508..2e374aaca3 100644--- a/web/packages/new/photos/services/ml/worker.ts+++ b/web/packages/new/photos/services/ml/worker.ts@@ -373,7 +373,7 @@ const indexNextBatch = async (}// Keep track if any of the items failed.- let allSuccess = true;+ let failureCount = 0;// Index up to 4 items simultaneously.const tasks = new Array<Promise<void> | undefined>(4).fill(undefined);@@ -389,8 +389,10 @@ const indexNextBatch = async (.then(() => {tasks[j] = undefined;})- .catch(() => {- allSuccess = false;+ .catch((e: unknown) => {+ const f = fileLogID(item.file);+ log.error(`Failed to index ${f}`, e);+ failureCount++;tasks[j] = undefined;}))(items[i++]!, j);}@@ -414,8 +416,14 @@ const indexNextBatch = async (// Clear any cached CLIP indexes, since now we might have new ones.clearCachedCLIPIndexes();+ log.info(+ failureCount > 0+ ? `Indexed ${items.length - failureCount} files (${failureCount} failed)`+ : `Indexed ${items.length} files`,+ );+// Return true if nothing failed.- return allSuccess;+ return failureCount == 0;};/**@@ -524,15 +532,10 @@ const index = async (// and return.if (existingFaceIndex && existingCLIPIndex) {- try {- await saveIndexes(- { fileID, ...existingFaceIndex },- { fileID, ...existingCLIPIndex },- );- } catch (e) {- log.error(`Failed to save indexes for ${f}`, e);- throw e;- }+ await saveIndexes(+ { fileID, ...existingFaceIndex },+ { fileID, ...existingCLIPIndex },+ );return;}@@ -554,7 +557,6 @@ const index = async (// reindexing attempt for failed files).//// See: [Note: Transient and permanent indexing failures]- log.error(`Failed to get image data for indexing ${f}`, e);await markIndexingFailed(file.id);throw e;}@@ -572,7 +574,6 @@ const index = async (]);} catch (e) {// See: [Note: Transient and permanent indexing failures]- log.error(`Failed to index ${f}`, e);await markIndexingFailed(file.id);throw e;}@@ -614,33 +615,21 @@ const index = async (await putMLData(file, rawMLData);} catch (e) {// See: [Note: Transient and permanent indexing failures]- log.error(`Failed to put ML data for ${f}`, e);if (isHTTP4xxError(e)) await markIndexingFailed(file.id);throw e;}- try {- await saveIndexes(- { fileID, ...faceIndex },- { fileID, ...clipIndex },- );- } catch (e) {- // Not sure if DB failures should be considered permanent or- // transient. There isn't a known case where writing to the local- // indexedDB should systematically fail. It could fail if there was- // no space on device, but that's eminently retriable.- log.error(`Failed to save indexes for ${f}`, e);- throw e;- }+ await saveIndexes({ fileID, ...faceIndex }, { fileID, ...clipIndex });// This step, saving face crops, is conceptually not part of the// indexing pipeline; we just do it here since we have already have the- // ImageBitmap at hand. Ignore errors that happen during this since it- // does not impact the generated face index.+ // ImageBitmap at hand.if (!existingFaceIndex) {try {await saveFaceCrops(image.bitmap, faceIndex);} catch (e) {+ // Ignore errors that happen during this since it does not+ // impact the generated face index.log.error(`Failed to save face crops for ${f}`, e);}}