fix: Do not fail attachment model delete (#10744)

This commit is contained in:
Tom Moor authored and GitHub committed 2025-11-28 15:05:02 +01:00
1 parent 7ce407910e
commit 65db323ce6
1 file changed
+14 -1
+14 -1
View File
@@ -31,6 +31,7 @@ import IdModel from "./base/IdModel";
import { SkipChangeset } from "./decorators/Changeset";
import Fix from "./decorators/Fix";
import Length from "./validators/Length";
import Logger from "@server/logging/Logger";
@Table({ tableName: "attachments", modelName: "attachment" })
@Fix
@@ -161,7 +162,19 @@ class Attachment extends IdModel<
@BeforeDestroy
static async deleteAttachmentFromS3(model: Attachment) {
await FileStorage.deleteFile(model.key);
try {
await FileStorage.deleteFile(model.key);
} catch (err) {
// do not block deletion of the database record if S3 deletion fails
Logger.warn(
`Failed to delete attachment file ${model.key} from storage`,
{
id: model.id,
teamId: model.teamId,
message: err.message,
}
);
}
}
// static methods