mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 18:36:30 +01:00 
			
		
		
		
	fix(export/share): missing files and wrong meta handling
This commit is contained in:
		| @@ -3,7 +3,7 @@ | |||||||
| import dateUtils from "../date_utils.js"; | import dateUtils from "../date_utils.js"; | ||||||
| import path from "path"; | import path from "path"; | ||||||
| import packageInfo from "../../../package.json" with { type: "json" }; | import packageInfo from "../../../package.json" with { type: "json" }; | ||||||
| import { getContentDisposition, escapeHtml, getResourceDir, isDev } from "../utils.js"; | import { getContentDisposition } from "../utils.js"; | ||||||
| import protectedSessionService from "../protected_session.js"; | import protectedSessionService from "../protected_session.js"; | ||||||
| import sanitize from "sanitize-filename"; | import sanitize from "sanitize-filename"; | ||||||
| import fs from "fs"; | import fs from "fs"; | ||||||
| @@ -415,24 +415,6 @@ async function exportToZip(taskContext: TaskContext<"export">, branch: BBranch, | |||||||
|             } |             } | ||||||
|             return; |             return; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         const metaFileJson = JSON.stringify(metaFile, null, "\t"); |  | ||||||
|  |  | ||||||
|         archive.append(metaFileJson, { name: "!!!meta.json" }); |  | ||||||
|  |  | ||||||
|         saveNote(rootMeta, ""); |  | ||||||
|  |  | ||||||
|         const note = branch.getNote(); |  | ||||||
|         const zipFileName = `${branch.prefix ? `${branch.prefix} - ` : ""}${note.getTitleOrProtected() || "note"}.zip`; |  | ||||||
|  |  | ||||||
|         if (setHeaders && "setHeader" in res) { |  | ||||||
|             res.setHeader("Content-Disposition", getContentDisposition(zipFileName)); |  | ||||||
|             res.setHeader("Content-Type", "application/zip"); |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         archive.pipe(res); |  | ||||||
|         await archive.finalize(); |  | ||||||
|         taskContext.taskSucceeded(null); |  | ||||||
|     } catch (e: unknown) { |     } catch (e: unknown) { | ||||||
|         const message = `Export failed with error: ${e instanceof Error ? e.message : String(e)}`; |         const message = `Export failed with error: ${e instanceof Error ? e.message : String(e)}`; | ||||||
|         log.error(message); |         log.error(message); | ||||||
|   | |||||||
| @@ -166,7 +166,7 @@ export default class HtmlExportProvider extends ZipExportProvider { | |||||||
|         } |         } | ||||||
|  |  | ||||||
|         const cssFile = isDev |         const cssFile = isDev | ||||||
|             ? path.join(__dirname, "../../../../../node_modules/ckeditor5/dist/ckeditor5-content.css") |             ? path.join(__dirname, "../../../../../../node_modules/ckeditor5/dist/ckeditor5-content.css") | ||||||
|             : path.join(getResourceDir(), "ckeditor5-content.css"); |             : path.join(getResourceDir(), "ckeditor5-content.css"); | ||||||
|         const cssContent = fs.readFileSync(cssFile, "utf-8"); |         const cssContent = fs.readFileSync(cssFile, "utf-8"); | ||||||
|         this.archive.append(cssContent, { name: cssMeta.dataFileName }); |         this.archive.append(cssContent, { name: cssMeta.dataFileName }); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user