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 { try {
log.info(`${logId}: Starting job`); 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({ const result = await runDownloadAttachmentJobInner({
job, job,
abortSignal: options.abortSignal, abortSignal: options.abortSignal,
@@ -576,6 +566,16 @@ export async function runDownloadAttachmentJobInner({
{ type: attachmentType } { 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 { try {
const { downloadPath } = attachment; const { downloadPath } = attachment;
let totalDownloaded = 0; let totalDownloaded = 0;

View File

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