Cleanup attachment download flow
This commit is contained in:
parent
9ad0e5064d
commit
ff5ecd8bf3
4 changed files with 16 additions and 25 deletions
|
@ -31,6 +31,7 @@ import {
|
|||
getMaximumIncomingAttachmentSizeInKb,
|
||||
getMaximumIncomingTextAttachmentSizeInKb,
|
||||
} from '../types/AttachmentSize';
|
||||
import { redactCdnKey } from '../util/privacy';
|
||||
|
||||
const {
|
||||
getMessageById,
|
||||
|
@ -221,7 +222,6 @@ async function _maybeStartJob(): Promise<void> {
|
|||
const logId = `attachment_downloads/_maybeStartJob/postProcess/${job.id}`;
|
||||
try {
|
||||
await promise;
|
||||
log.info(`${logId}: job has finished running`);
|
||||
if (_activeAttachmentDownloadJobs[job.id]) {
|
||||
throw new Error(
|
||||
`${logId}: Active attachments jobs list still has this job!`
|
||||
|
@ -269,12 +269,18 @@ async function _runJob(job?: AttachmentDownloadJobType): Promise<void> {
|
|||
);
|
||||
}
|
||||
|
||||
logger.info(`attachment_downloads/_runJob(${id}): starting`);
|
||||
|
||||
const pending = true;
|
||||
await setAttachmentDownloadJobPending(id, pending);
|
||||
|
||||
message = await _getMessageById(id, messageId);
|
||||
logger.info(
|
||||
'attachment_downloads/_runJob' +
|
||||
`(jobId: ${id}, type: ${type}, index: ${index},` +
|
||||
` cdnKey: ${
|
||||
attachment.cdnKey ? redactCdnKey(attachment.cdnKey) : null
|
||||
},` +
|
||||
` messageTimestamp: ${message?.attributes.timestamp}): starting`
|
||||
);
|
||||
|
||||
if (!message) {
|
||||
return;
|
||||
|
@ -475,10 +481,6 @@ async function _finishJob(
|
|||
await saveMessage(message.attributes, {
|
||||
ourAci: window.textsecure.storage.user.getCheckedAci(),
|
||||
});
|
||||
} else {
|
||||
logger.info(
|
||||
`attachment_downloads/_finishJob for job id: ${id} without message`
|
||||
);
|
||||
}
|
||||
|
||||
await removeAttachmentDownloadJob(id);
|
||||
|
@ -525,8 +527,6 @@ async function _addAttachmentToMessage(
|
|||
const logPrefix = `${message.idForLogging()} (type: ${type}, index: ${index})`;
|
||||
const attachmentSignature = getAttachmentSignature(attachment);
|
||||
|
||||
log.info(`${logPrefix}: _addAttachmentToMessage: starting`);
|
||||
|
||||
if (type === 'long-message') {
|
||||
let handledAnywhere = false;
|
||||
let attachmentData: Uint8Array | undefined;
|
||||
|
@ -612,7 +612,6 @@ async function _addAttachmentToMessage(
|
|||
`${logPrefix}: Long message attachment found no matching place to apply`
|
||||
);
|
||||
}
|
||||
log.info(`${logPrefix}: _addAttachmentToMessage finished`);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue