From e3e51092709bfc3f0792ce2a7fe5bd2a220ae1af Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Mon, 3 Nov 2025 15:49:31 +0200 Subject: [PATCH] feat(export/share): export without inner subdirectory --- apps/server/src/services/export/zip.ts | 6 ++++-- apps/server/src/services/export/zip/share_theme.ts | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/apps/server/src/services/export/zip.ts b/apps/server/src/services/export/zip.ts index 3043e1636..e29cb6121 100644 --- a/apps/server/src/services/export/zip.ts +++ b/apps/server/src/services/export/zip.ts @@ -371,10 +371,12 @@ async function exportToZip(taskContext: TaskContext<"export">, branch: BBranch, } if (noteMeta.children?.length || 0 > 0) { - const directoryPath = filePathPrefix + noteMeta.dirFileName; + const directoryPath = filePathPrefix !== "" || format !== "share" ? filePathPrefix + noteMeta.dirFileName : ""; // create directory - archive.append("", { name: `${directoryPath}/`, date: dateUtils.parseDateTime(note.utcDateModified) }); + if (directoryPath) { + archive.append("", { name: `${directoryPath}/`, date: dateUtils.parseDateTime(note.utcDateModified) }); + } for (const childMeta of noteMeta.children || []) { saveNote(childMeta, `${directoryPath}/`); diff --git a/apps/server/src/services/export/zip/share_theme.ts b/apps/server/src/services/export/zip/share_theme.ts index f06871857..03ea478c8 100644 --- a/apps/server/src/services/export/zip/share_theme.ts +++ b/apps/server/src/services/export/zip/share_theme.ts @@ -58,7 +58,7 @@ export default class ShareThemeExportProvider extends ZipExportProvider { if (!noteMeta?.notePath?.length) { throw new Error("Missing note path."); } - const basePath = "../".repeat(noteMeta.notePath.length - 1); + const basePath = "../".repeat(Math.max(0, noteMeta.notePath.length - 2)); let searchContent = ""; if (note) {