Cleanup attachment download flow
This commit is contained in:
parent
9ad0e5064d
commit
ff5ecd8bf3
4 changed files with 16 additions and 25 deletions
|
@ -27,6 +27,7 @@ import {
|
|||
import type { ProcessedAttachment } from './Types.d';
|
||||
import type { WebAPIType } from './WebAPI';
|
||||
import { createName, getRelativePath } from '../windows/attachments';
|
||||
import { redactCdnKey } from '../util/privacy';
|
||||
|
||||
export function getCdn(attachment: ProcessedAttachment): string {
|
||||
const { cdnId, cdnKey } = attachment;
|
||||
|
@ -89,7 +90,7 @@ export async function downloadAttachmentV2(
|
|||
): Promise<AttachmentType> {
|
||||
const { cdnNumber, contentType, digest, key, size } = attachment;
|
||||
const cdn = getCdn(attachment);
|
||||
const logId = `downloadAttachmentV2(${cdn}):`;
|
||||
const logId = `downloadAttachmentV2(${redactCdnKey(cdn)}:`;
|
||||
|
||||
strictAssert(digest, `${logId}: missing digest`);
|
||||
strictAssert(key, `${logId}: missing key`);
|
||||
|
@ -100,11 +101,8 @@ export async function downloadAttachmentV2(
|
|||
dropNull(cdnNumber),
|
||||
options
|
||||
);
|
||||
log.info(`${logId} got download stream`);
|
||||
|
||||
const cipherTextRelativePath = await downloadToDisk({ downloadStream, size });
|
||||
log.info(`${logId} downloaded encrypted file to disk`);
|
||||
|
||||
const cipherTextAbsolutePath =
|
||||
window.Signal.Migrations.getAbsoluteAttachmentPath(cipherTextRelativePath);
|
||||
|
||||
|
@ -115,7 +113,6 @@ export async function downloadAttachmentV2(
|
|||
size,
|
||||
theirDigest: Bytes.fromBase64(digest),
|
||||
});
|
||||
log.info(`${logId} successfully decrypted`);
|
||||
|
||||
safeUnlinkSync(cipherTextAbsolutePath);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue