Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

mobile: retry file size check on thrown network errors, not just bad responses

kashaf-ansari-dev19c1d1798101
diff --git a/apps/mobile/app/common/filesystem/utils.ts b/apps/mobile/app/common/filesystem/utils.ts
index e5f87a39e..e04a6bc25 100644
--- a/apps/mobile/app/common/filesystem/utils.ts
+++ b/apps/mobile/app/common/filesystem/utils.ts
@@ -145,6 +145,13 @@ export async function getUploadedFileSize(hash: string, retry = 0) {
const contentLength = parseInt(fileSize as string);
return isNaN(contentLength) ? FileSizeResult.Empty : contentLength;
} catch (e) {
+ if (retry < 3) {
+ DatabaseLogger.log(
+ `Retrying file size check after error: ${hash}, ${retry}`
+ );
+ await new Promise((resolve) => setTimeout(resolve, 500 * (retry + 1)));
+ return getUploadedFileSize(hash, retry + 1);
+ }
DatabaseLogger.error(e);
return FileSizeResult.Error;
}