Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 5d0b513

Browse files
authored
Treat thumbnail upload failures as complete upload failures (#10829)
Without this it'll be treated the same as a thumbnailing failure which falls back to m.file
1 parent 9b6973d commit 5d0b513

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/ContentMessages.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,14 @@ import encrypt from "matrix-encrypt-attachment";
2222
import extractPngChunks from "png-chunks-extract";
2323
import { IImageInfo } from "matrix-js-sdk/src/@types/partials";
2424
import { logger } from "matrix-js-sdk/src/logger";
25-
import { IEventRelation, ISendEventResponse, MatrixEvent, UploadOpts, UploadProgress } from "matrix-js-sdk/src/matrix";
25+
import {
26+
HTTPError,
27+
IEventRelation,
28+
ISendEventResponse,
29+
MatrixEvent,
30+
UploadOpts,
31+
UploadProgress,
32+
} from "matrix-js-sdk/src/matrix";
2633
import { THREAD_RELATION_TYPE } from "matrix-js-sdk/src/models/thread";
2734
import { removeElement } from "matrix-js-sdk/src/utils";
2835

@@ -526,7 +533,11 @@ export default class ContentMessages {
526533
const imageInfo = await infoForImageFile(matrixClient, roomId, file);
527534
Object.assign(content.info, imageInfo);
528535
} catch (e) {
529-
// Failed to thumbnail, fall back to uploading an m.file
536+
if (e instanceof HTTPError) {
537+
// re-throw to main upload error handler
538+
throw e;
539+
}
540+
// Otherwise we failed to thumbnail, fall back to uploading an m.file
530541
logger.error(e);
531542
content.msgtype = MsgType.File;
532543
}

0 commit comments

Comments
 (0)