Backfill improvements

This commit is contained in:
Fedor Indutny
2025-03-26 14:58:11 -07:00
committed by GitHub
parent c5838f3701
commit 58da01ed51
2 changed files with 12 additions and 11 deletions

View File

@@ -364,16 +364,6 @@ async function runDownloadAttachmentJob({
try {
log.info(`${logId}: Starting job`);
if (
job.source !== AttachmentDownloadSource.BACKFILL &&
isPermanentlyUndownloadableWithoutBackfill(job.attachment)
) {
// We should only get to here only if
throw new AttachmentPermanentlyUndownloadableError(
'Not downloadable without backfill'
);
}
const result = await runDownloadAttachmentJobInner({
job,
abortSignal: options.abortSignal,
@@ -576,6 +566,16 @@ export async function runDownloadAttachmentJobInner({
{ type: attachmentType }
);
if (
job.source !== AttachmentDownloadSource.BACKFILL &&
isPermanentlyUndownloadableWithoutBackfill(job.attachment)
) {
// We should only get to here only if
throw new AttachmentPermanentlyUndownloadableError(
'Not downloadable without backfill'
);
}
try {
const { downloadPath } = attachment;
let totalDownloaded = 0;

View File

@@ -100,7 +100,7 @@ export class AttachmentBackfill {
timestamp,
response,
}: AttachmentBackfillResponseSyncEvent): Promise<void> {
const logId = `onAttachmentBackfillResponseSync(${timestamp})`;
let logId = `onAttachmentBackfillResponseSync(${timestamp})`;
if (!isBackfillEnabled()) {
log.info(`${logId}: disabled`);
return;
@@ -129,6 +129,7 @@ export class AttachmentBackfill {
}
const message = window.MessageCache.register(new MessageModel(attributes));
logId += `(${message.get('sent_at')})`;
const timer = this.#pendingRequests.get(message.id);
if (timer != null) {