Skip to content

Build your personal knowledge base with Trilium Notes

fix(standalone): unable to download ZIPs

Elian Doran8b1d0063ffe3
diff --git a/packages/trilium-core/src/routes/api/export.ts b/packages/trilium-core/src/routes/api/export.ts
index 00600f67ed..88af5f2e32 100644
--- a/packages/trilium-core/src/routes/api/export.ts
+++ b/packages/trilium-core/src/routes/api/export.ts
@@ -9,7 +9,7 @@ import TaskContext from "../../services/task_context.js";
import { safeExtractMessageAndStackFromError } from "../../services/utils/index.js";
import { NotFoundError, ValidationError } from "../../errors.js";
-function exportBranch(req: Request<{ branchId: string; type: string; format: string; version: string; taskId: string }>, res: Response) {
+async function exportBranch(req: Request<{ branchId: string; type: string; format: string; version: string; taskId: string }>, res: Response) {
const { branchId, type, format, version, taskId } = req.params;
const branch = becca.getBranch(branchId);
@@ -25,7 +25,7 @@ function exportBranch(req: Request<{ branchId: string; type: string; format: str
try {
if (type === "subtree" && (format === "html" || format === "markdown" || format === "share")) {
- zipExportService.exportToZip(taskContext, branch, format, res);
+ await zipExportService.exportToZip(taskContext, branch, format, res);
} else if (type === "single") {
if (format !== "html" && format !== "markdown") {
throw new ValidationError("Invalid export type.");
diff --git a/packages/trilium-core/src/routes/index.ts b/packages/trilium-core/src/routes/index.ts
index 6e03eaf307..2c276b40ce 100644
--- a/packages/trilium-core/src/routes/index.ts
+++ b/packages/trilium-core/src/routes/index.ts
@@ -144,7 +144,7 @@ export function buildSharedApiRoutes({ route, asyncRoute, apiRoute, asyncApiRout
//#region Import/export
asyncRoute(PST, "/api/notes/:parentNoteId/notes-import", [checkApiAuthOrElectron, uploadMiddlewareWithErrorHandling, csrfMiddleware], importRoute.importNotesToBranch, apiResultHandler);
route(PST, "/api/notes/:parentNoteId/attachments-import", [checkApiAuthOrElectron, uploadMiddlewareWithErrorHandling, csrfMiddleware], importRoute.importAttachmentsToNote, apiResultHandler);
- route(GET, "/api/branches/:branchId/export/:type/:format/:version/:taskId", [checkApiAuthOrElectron], exportRoute.exportBranch);
+ asyncRoute(GET, "/api/branches/:branchId/export/:type/:format/:version/:taskId", [checkApiAuthOrElectron], exportRoute.exportBranch);
//#endregion
apiRoute(GET, "/api/quick-search/:searchString", searchRoute.quickSearch);