Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
fix setting exported file extension when truncated
zadam1aff42f453b0
diff --git a/src/services/export/zip.js b/src/services/export/zip.jsindex 1af8efa7b6..ffed0f5d99 100644--- a/src/services/export/zip.js+++ b/src/services/export/zip.js@@ -50,7 +50,13 @@ function exportToZip(taskContext, branch, format, res) {}function getDataFileName(note, baseFileName, existingFileNames) {- const existingExtension = path.extname(baseFileName).toLowerCase();+ let fileName = baseFileName;++ if (fileName.length > 30) {+ fileName = fileName.substr(0, 30);+ }++ let existingExtension = path.extname(fileName).toLowerCase();let newExtension;// following two are handled specifically since we always want to have these extensions no matter the automatic detection@@ -68,13 +74,12 @@ function exportToZip(taskContext, branch, format, res) {newExtension = null;}else {- newExtension = mimeTypes.extension(note.mime) || "dat";- }-- let fileName = baseFileName;-- if (fileName.length > 30) {- fileName = fileName.substr(0, 30);+ if (note.mime?.toLowerCase()?.trim() === "image/jpg") {+ newExtension = 'jpg';+ }+ else {+ newExtension = mimeTypes.extension(note.mime) || "dat";+ }}// if the note is already named with extension (e.g. "jquery"), then it's silly to append exact same extension again