web: fix attachment not getting marked as failed on error

This commit is contained in:
Abdullah Atta
2024-05-04 17:00:47 +05:00
committed by Abdullah Atta
parent b22770f1ae
commit 00754593ac

View File

@@ -497,13 +497,13 @@ async function downloadFile(
); );
if (contentLength === 0 || isNaN(contentLength)) { if (contentLength === 0 || isNaN(contentLength)) {
const error = `File length is 0. Please upload this file again from the attachment manager. (File hash: ${filename})`; const error = `File length is 0. Please upload this file again from the attachment manager. (File hash: ${filename})`;
await db.attachments.markAsFailed(filename, error); await db.attachments.markAsFailed(attachment.id, error);
throw new Error(error); throw new Error(error);
} }
if (!response.body) { if (!response.body) {
const error = `The download response does not contain a body. Please upload this file again from the attachment manager. (File hash: ${filename})`; const error = `The download response does not contain a body. Please upload this file again from the attachment manager. (File hash: ${filename})`;
await db.attachments.markAsFailed(filename, error); await db.attachments.markAsFailed(attachment.id, error);
throw new Error(error); throw new Error(error);
} }
@@ -511,7 +511,7 @@ async function downloadFile(
const decryptedLength = contentLength - totalChunks * ABYTES; const decryptedLength = contentLength - totalChunks * ABYTES;
if (attachment && attachment.size !== decryptedLength) { if (attachment && attachment.size !== decryptedLength) {
const error = `File length mismatch. Please upload this file again from the attachment manager. (File hash: ${filename})`; const error = `File length mismatch. Please upload this file again from the attachment manager. (File hash: ${filename})`;
await db.attachments.markAsFailed(filename, error); await db.attachments.markAsFailed(attachment.id, error);
throw new Error(error); throw new Error(error);
} }