mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2026-05-08 17:08:57 +01:00
Cleanup attachment download flow
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user