fix: Skip attachment work in exports when includeAttachments is false (#12933)

Gate the workspace attachment-size query behind includeAttachments so it
no longer runs when attachments are excluded, and thread includeAttachments
through the single-document export path (previously hardcoded to true).

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Tom MoorandClaude Opus 4.8 authored and GitHub committed 2026-07-08 10:20:18 +02:00
1 parent 25e8b6f518
commit 8ea04c3bd4
4 files changed
+23 -12

No files matched your search

@@ -166,11 +166,13 @@ export default abstract class ExportDocumentTreeTask extends ExportTask {
format,
documentStructure,
zip,
includeAttachments = true,
}: {
document: Document;
format: FileOperationFormat;
documentStructure: NavigationNode[];
zip: ZipFile;
includeAttachments?: boolean;
}) {
const pathMap = new Map<string, string>();
@@ -191,7 +193,7 @@ export default abstract class ExportDocumentTreeTask extends ExportTask {
zip,
pathMap,
format,
includeAttachments: true,
includeAttachments,
});
return await ZipHelper.toTmpFile(zip);
+3 -1
View File
@@ -22,7 +22,8 @@ export default class ExportHTMLZipTask extends ExportDocumentTreeTask {
public async exportDocument(
document: Document,
documentStructure: NavigationNode[]
documentStructure: NavigationNode[],
includeAttachments: boolean
): Promise<string> {
const zip = new ZipFile();
@@ -31,6 +32,7 @@ export default class ExportHTMLZipTask extends ExportDocumentTreeTask {
documentStructure,
format: FileOperationFormat.HTMLZip,
zip,
includeAttachments,
});
}
}
+3 -1
View File
@@ -22,7 +22,8 @@ export default class ExportMarkdownZipTask extends ExportDocumentTreeTask {
public async exportDocument(
document: Document,
documentStructure: NavigationNode[]
documentStructure: NavigationNode[],
includeAttachments: boolean
): Promise<string> {
const zip = new ZipFile();
@@ -31,6 +32,7 @@ export default class ExportMarkdownZipTask extends ExportDocumentTreeTask {
documentStructure,
format: FileOperationFormat.MarkdownZip,
zip,
includeAttachments,
});
}
}
+14 -9
View File
@@ -140,21 +140,25 @@ export default abstract class ExportTask extends BaseTask<Props> {
throw new Error("Document not found in collection tree");
}
return this.exportDocument(document, documentStructure.children ?? []);
return this.exportDocument(
document,
documentStructure.children ?? [],
fileOperation.options?.includeAttachments ?? true
);
}
// ensure attachment size is within limits
if (!fileOperation.collectionId) {
if (
!fileOperation.collectionId &&
fileOperation.options?.includeAttachments &&
env.MAXIMUM_EXPORT_SIZE
) {
const totalAttachmentsSize = await Attachment.getTotalSizeForTeam(
sequelizeReadOnly,
user.teamId
);
if (
fileOperation.options?.includeAttachments &&
env.MAXIMUM_EXPORT_SIZE &&
totalAttachmentsSize > env.MAXIMUM_EXPORT_SIZE
) {
if (totalAttachmentsSize > env.MAXIMUM_EXPORT_SIZE) {
throw ValidationError(
`${bytesToHumanReadable(
totalAttachmentsSize
@@ -208,12 +212,13 @@ export default abstract class ExportTask extends BaseTask<Props> {
*
* @param document The document to export
* @param documentStructure Structure of document's children
* @param fileOperation File operation associated with the export
* @param includeAttachments Whether to include attachments in the export
* @returns A promise that resolves to a temporary file path
*/
protected abstract exportDocument(
document: Document,
documentStructure: NavigationNode[]
documentStructure: NavigationNode[],
includeAttachments: boolean
): Promise<string>;
/**