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