mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2025-12-24 20:26:24 +00:00
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:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user