Erased messages should not stall attachment jobs
This commit is contained in:
parent
10a0abb8c2
commit
6476a4fe73
1 changed files with 37 additions and 31 deletions
|
@ -286,12 +286,15 @@ async function _runJob(job?: AttachmentDownloadJobType): Promise<void> {
|
||||||
Errors.toLogFormat(error)
|
Errors.toLogFormat(error)
|
||||||
);
|
);
|
||||||
|
|
||||||
await _addAttachmentToMessage(
|
try {
|
||||||
message,
|
await _addAttachmentToMessage(
|
||||||
_markAttachmentAsTransientError(attachment),
|
message,
|
||||||
{ type, index }
|
_markAttachmentAsTransientError(attachment),
|
||||||
);
|
{ type, index }
|
||||||
await _finishJob(message, id);
|
);
|
||||||
|
} finally {
|
||||||
|
await _finishJob(message, id);
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -302,32 +305,35 @@ async function _runJob(job?: AttachmentDownloadJobType): Promise<void> {
|
||||||
Errors.toLogFormat(error)
|
Errors.toLogFormat(error)
|
||||||
);
|
);
|
||||||
|
|
||||||
// Remove `pending` flag from the attachment.
|
try {
|
||||||
await _addAttachmentToMessage(
|
// Remove `pending` flag from the attachment.
|
||||||
message,
|
await _addAttachmentToMessage(
|
||||||
{
|
message,
|
||||||
...attachment,
|
{
|
||||||
downloadJobId: id,
|
...attachment,
|
||||||
},
|
downloadJobId: id,
|
||||||
{ type, index }
|
},
|
||||||
);
|
{ type, index }
|
||||||
if (message) {
|
);
|
||||||
await saveMessage(message.attributes, {
|
if (message) {
|
||||||
ourUuid: window.textsecure.storage.user.getCheckedUuid().toString(),
|
await saveMessage(message.attributes, {
|
||||||
});
|
ourUuid: window.textsecure.storage.user.getCheckedUuid().toString(),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const failedJob = {
|
||||||
|
...job,
|
||||||
|
pending: 0,
|
||||||
|
attempts: currentAttempt,
|
||||||
|
timestamp:
|
||||||
|
Date.now() + (RETRY_BACKOFF[currentAttempt] || RETRY_BACKOFF[3]),
|
||||||
|
};
|
||||||
|
|
||||||
|
await saveAttachmentDownloadJob(failedJob);
|
||||||
|
} finally {
|
||||||
|
delete _activeAttachmentDownloadJobs[id];
|
||||||
|
_maybeStartJob();
|
||||||
}
|
}
|
||||||
|
|
||||||
const failedJob = {
|
|
||||||
...job,
|
|
||||||
pending: 0,
|
|
||||||
attempts: currentAttempt,
|
|
||||||
timestamp:
|
|
||||||
Date.now() + (RETRY_BACKOFF[currentAttempt] || RETRY_BACKOFF[3]),
|
|
||||||
};
|
|
||||||
|
|
||||||
await saveAttachmentDownloadJob(failedJob);
|
|
||||||
delete _activeAttachmentDownloadJobs[id];
|
|
||||||
_maybeStartJob();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue