Allow for zero-size attachments in maximum size calculation

Co-authored-by: Scott Nonnenberg <scott@signal.org>
This commit is contained in:
automated-signal
2024-03-01 17:36:45 -06:00
committed by GitHub
parent 3f8206e66f
commit f0975c2fd0

View File

@@ -289,7 +289,7 @@ async function _runJob(job?: AttachmentDownloadJobType): Promise<void> {
const { size } = attachment;
const sizeInKib = size / KIBIBYTE;
if (!size || sizeInKib > maxInKib) {
if (!Number.isFinite(size) || size < 0 || sizeInKib > maxInKib) {
throw new AttachmentSizeError(
`Attachment Job ${id}: Attachment was ${sizeInKib}kib, max is ${maxInKib}kib`
);