Allow for zero-size attachments in maximum size calculation

This commit is contained in:
Scott Nonnenberg 2024-03-01 11:15:24 -08:00 committed by GitHub
parent e7dbdeb9c2
commit e5e4c1aa3e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

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