Error loading attachment should not fail entire export. closes #6158

This commit is contained in:
Tom Moor
2023-11-15 20:38:54 -05:00
parent cf6a946c9c
commit a0b51b8c71
3 changed files with 66 additions and 48 deletions

View File

@@ -94,22 +94,28 @@ export default class ExportJSONTask extends ExportTask {
await Promise.all(
attachments.map(async (attachment) => {
try {
zip.file(attachment.key, attachment.buffer, {
zip.file(
attachment.key,
new Promise<Buffer>((resolve) => {
attachment.buffer.then(resolve).catch((err) => {
Logger.warn(`Failed to read attachment from S3`, {
attachmentId: attachment.id,
teamId: attachment.teamId,
error: err.message,
});
resolve(Buffer.from(""));
});
}),
{
date: attachment.updatedAt,
createFolders: true,
});
}
);
output.attachments[attachment.id] = {
...omit(presentAttachment(attachment), "url"),
key: attachment.key,
};
} catch (err) {
Logger.error(
`Failed to add attachment to archive: ${attachment.key}`,
err
);
}
output.attachments[attachment.id] = {
...omit(presentAttachment(attachment), "url"),
key: attachment.key,
};
})
);