Use streams to download attachments directly to disk

Co-authored-by: trevor-signal <131492920+trevor-signal@users.noreply.github.com>
This commit is contained in:
Scott Nonnenberg
2023-10-30 09:24:28 -07:00
committed by GitHub
parent 2da49456c6
commit 99b2bc304e
48 changed files with 2297 additions and 356 deletions

View File

@@ -37,6 +37,8 @@ const MIN_HEIGHT = 50;
// Used for display
export class AttachmentSizeError extends Error {}
export type AttachmentType = {
error?: boolean;
blurHash?: string;
@@ -75,6 +77,7 @@ export type AttachmentType = {
key?: string;
data?: Uint8Array;
textAttachment?: TextAttachmentType;
wasTooBig?: boolean;
/** Legacy field. Used only for downloading old attachments */
id?: number;
@@ -1008,9 +1011,9 @@ export const defaultBlurHash = (theme: ThemeType = ThemeType.light): string => {
};
export const canBeDownloaded = (
attachment: Pick<AttachmentType, 'key' | 'digest'>
attachment: Pick<AttachmentType, 'digest' | 'key' | 'wasTooBig'>
): boolean => {
return Boolean(attachment.key && attachment.digest);
return Boolean(attachment.digest && attachment.key && !attachment.wasTooBig);
};
export function getAttachmentSignature(attachment: AttachmentType): string {