AttachmentDownloads: Log second error, finish job even on failures

This commit is contained in:
Scott Nonnenberg 2023-01-13 11:18:59 -08:00 committed by GitHub
parent 662223df32
commit ef20c31c64
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -226,7 +226,7 @@ async function _maybeStartJob(): Promise<void> {
} catch (deleteError) {
log.error(
`${logId}: Failed to delete attachment job`,
Errors.toLogFormat(error)
Errors.toLogFormat(deleteError)
);
} finally {
void _maybeStartJob();
@ -371,16 +371,18 @@ async function _markAttachmentAsFailed(
const { id, messageId, attachment, type, index } = job;
const message = await _getMessageById(id, messageId);
if (!message) {
return;
try {
if (!message) {
return;
}
await _addAttachmentToMessage(
message,
_markAttachmentAsPermanentError(attachment),
{ type, index }
);
} finally {
await _finishJob(message, id);
}
await _addAttachmentToMessage(
message,
_markAttachmentAsPermanentError(attachment),
{ type, index }
);
await _finishJob(message, id);
}
async function _getMessageById(