Skip to content

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

mobile: Incorrect math for determining total number of chunks causes erroneous assertation that there is one more chunk in certain conditions.

Chloe Oletto011cc992e845
diff --git a/apps/mobile/app/common/filesystem/download.ts b/apps/mobile/app/common/filesystem/download.ts
index 1448d2875..110aa335c 100644
--- a/apps/mobile/app/common/filesystem/download.ts
+++ b/apps/mobile/app/common/filesystem/download.ts
@@ -70,7 +70,7 @@ export async function downloadFile(
throw new Error(error);
}
- const totalChunks = Math.ceil(size / chunkSize);
+ const totalChunks = Math.ceil(size / (chunkSize + ABYTES));
const decryptedLength = size - totalChunks * ABYTES;
if (attachment && attachment.size !== decryptedLength) {
diff --git a/apps/mobile/app/common/filesystem/utils.ts b/apps/mobile/app/common/filesystem/utils.ts
index 404dbd96b..6575587cb 100644
--- a/apps/mobile/app/common/filesystem/utils.ts
+++ b/apps/mobile/app/common/filesystem/utils.ts
@@ -155,7 +155,7 @@ export async function checkUpload(
expectedSize: number
) {
const size = await getUploadedFileSize(filename);
- const totalChunks = Math.ceil(size / chunkSize);
+ const totalChunks = Math.ceil(size / (chunkSize + ABYTES));
const decryptedLength = size - totalChunks * ABYTES;
const error =
size === 0