Add a backup media download progress bar

This commit is contained in:
trevor-signal
2024-09-03 18:00:51 -04:00
committed by GitHub
parent 84f1d98020
commit 501f27127f
31 changed files with 640 additions and 78 deletions

View File

@@ -32,6 +32,7 @@ import {
AttachmentDownloadManager,
AttachmentDownloadUrgency,
} from '../jobs/AttachmentDownloadManager';
import { AttachmentDownloadSource } from '../sql/Interface';
export type MessageAttachmentsDownloadedType = {
bodyAttachment?: AttachmentType;
@@ -62,7 +63,13 @@ function getAttachmentSignatureSafe(
// count then you'll also have to modify ./hasAttachmentsDownloads
export async function queueAttachmentDownloads(
message: MessageAttributesType,
urgency: AttachmentDownloadUrgency = AttachmentDownloadUrgency.STANDARD
{
urgency = AttachmentDownloadUrgency.STANDARD,
source = AttachmentDownloadSource.STANDARD,
}: {
urgency?: AttachmentDownloadUrgency;
source?: AttachmentDownloadSource;
} = {}
): Promise<MessageAttachmentsDownloadedType | undefined> {
const attachmentsToQueue = message.attachments || [];
const messageId = message.id;
@@ -109,6 +116,7 @@ export async function queueAttachmentDownloads(
receivedAt: message.received_at,
sentAt: message.sent_at,
urgency,
source,
});
}
@@ -126,6 +134,7 @@ export async function queueAttachmentDownloads(
receivedAt: message.received_at,
sentAt: message.sent_at,
urgency,
source,
}
);
count += attachmentsCount;
@@ -144,6 +153,7 @@ export async function queueAttachmentDownloads(
receivedAt: message.received_at,
sentAt: message.sent_at,
urgency,
source,
});
count += previewCount;
@@ -162,6 +172,7 @@ export async function queueAttachmentDownloads(
receivedAt: message.received_at,
sentAt: message.sent_at,
urgency,
source,
});
count += thumbnailCount;
@@ -194,6 +205,7 @@ export async function queueAttachmentDownloads(
receivedAt: message.received_at,
sentAt: message.sent_at,
urgency,
source,
}),
},
};
@@ -230,6 +242,7 @@ export async function queueAttachmentDownloads(
receivedAt: message.received_at,
sentAt: message.sent_at,
urgency,
source,
});
} else {
log.error(`${idLog}: Sticker data was missing`);
@@ -267,6 +280,7 @@ export async function queueAttachmentDownloads(
receivedAt: message.received_at,
sentAt: message.sent_at,
urgency,
source,
});
count += editAttachmentsCount;
if (editAttachmentsCount !== 0) {
@@ -285,6 +299,7 @@ export async function queueAttachmentDownloads(
receivedAt: message.received_at,
sentAt: message.sent_at,
urgency,
source,
});
count += editPreviewCount;
if (editPreviewCount !== 0) {
@@ -328,6 +343,7 @@ async function queueNormalAttachments({
receivedAt,
sentAt,
urgency,
source,
}: {
idLog: string;
messageId: string;
@@ -336,6 +352,7 @@ async function queueNormalAttachments({
receivedAt: number;
sentAt: number;
urgency: AttachmentDownloadUrgency;
source: AttachmentDownloadSource;
}): Promise<{
attachments: Array<AttachmentType>;
count: number;
@@ -393,6 +410,7 @@ async function queueNormalAttachments({
receivedAt,
sentAt,
urgency,
source,
});
})
);
@@ -426,6 +444,7 @@ async function queuePreviews({
receivedAt,
sentAt,
urgency,
source,
}: {
idLog: string;
messageId: string;
@@ -434,6 +453,7 @@ async function queuePreviews({
receivedAt: number;
sentAt: number;
urgency: AttachmentDownloadUrgency;
source: AttachmentDownloadSource;
}): Promise<{ preview: Array<LinkPreviewType>; count: number }> {
// Similar to queueNormalAttachments' logic for detecting same attachments
// except here we also pick by link preview URL.
@@ -485,6 +505,7 @@ async function queuePreviews({
receivedAt,
sentAt,
urgency,
source,
}),
};
})
@@ -518,6 +539,7 @@ async function queueQuoteAttachments({
receivedAt,
sentAt,
urgency,
source,
}: {
idLog: string;
messageId: string;
@@ -526,6 +548,7 @@ async function queueQuoteAttachments({
receivedAt: number;
sentAt: number;
urgency: AttachmentDownloadUrgency;
source: AttachmentDownloadSource;
}): Promise<{ quote?: QuotedMessageType; count: number }> {
let count = 0;
if (!quote) {
@@ -600,6 +623,7 @@ async function queueQuoteAttachments({
receivedAt,
sentAt,
urgency,
source,
}),
};
})