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
This commit is contained in:
Michael Telatynski 2023-05-09 10:52:07 +01:00 committed by GitHub
parent 9b6973d71a
commit 5d0b5131f2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -22,7 +22,14 @@ import encrypt from "matrix-encrypt-attachment";
import extractPngChunks from "png-chunks-extract"; import extractPngChunks from "png-chunks-extract";
import { IImageInfo } from "matrix-js-sdk/src/@types/partials"; import { IImageInfo } from "matrix-js-sdk/src/@types/partials";
import { logger } from "matrix-js-sdk/src/logger"; import { logger } from "matrix-js-sdk/src/logger";
import { IEventRelation, ISendEventResponse, MatrixEvent, UploadOpts, UploadProgress } from "matrix-js-sdk/src/matrix"; import {
HTTPError,
IEventRelation,
ISendEventResponse,
MatrixEvent,
UploadOpts,
UploadProgress,
} from "matrix-js-sdk/src/matrix";
import { THREAD_RELATION_TYPE } from "matrix-js-sdk/src/models/thread"; import { THREAD_RELATION_TYPE } from "matrix-js-sdk/src/models/thread";
import { removeElement } from "matrix-js-sdk/src/utils"; import { removeElement } from "matrix-js-sdk/src/utils";
@ -526,7 +533,11 @@ export default class ContentMessages {
const imageInfo = await infoForImageFile(matrixClient, roomId, file); const imageInfo = await infoForImageFile(matrixClient, roomId, file);
Object.assign(content.info, imageInfo); Object.assign(content.info, imageInfo);
} catch (e) { } catch (e) {
// Failed to thumbnail, fall back to uploading an m.file if (e instanceof HTTPError) {
// re-throw to main upload error handler
throw e;
}
// Otherwise we failed to thumbnail, fall back to uploading an m.file
logger.error(e); logger.error(e);
content.msgtype = MsgType.File; content.msgtype = MsgType.File;
} }