perf: Read attachment buffers only when neccessary, closes #3849

This commit is contained in:
Tom Moor
2022-07-24 19:15:34 +01:00
parent 71da57773e
commit 5e852170f9
3 changed files with 4 additions and 4 deletions

View File

@@ -71,7 +71,7 @@ export default class ImportMarkdownZipTask extends ImportTask {
name: child.name,
path: child.path,
mimeType: mime.lookup(child.path) || "application/octet-stream",
buffer: await zipObject.async("nodebuffer"),
buffer: () => zipObject.async("nodebuffer"),
});
return;
}

View File

@@ -82,7 +82,7 @@ export default class ImportNotionTask extends ImportTask {
name: child.name,
path: child.path,
mimeType,
buffer: await zipObject.async("nodebuffer"),
buffer: () => zipObject.async("nodebuffer"),
sourceId,
});
return;

View File

@@ -66,7 +66,7 @@ export type StructuredImportData = {
name: string;
path: string;
mimeType: string;
buffer: Buffer;
buffer: () => Promise<Buffer>;
/** Optional id from import source, useful for mapping */
sourceId?: string;
}[];
@@ -215,7 +215,7 @@ export default abstract class ImportTask extends BaseTask<Props> {
id: item.id,
name: item.name,
type: item.mimeType,
buffer: item.buffer,
buffer: await item.buffer(),
user,
ip,
transaction,