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
check the attachment after upload
zadam30bcd1764a66
diff --git a/src/becca/entities/bnote.js b/src/becca/entities/bnote.jsindex 4225908a9e..b009cef291 100644--- a/src/becca/entities/bnote.js+++ b/src/becca/entities/bnote.js@@ -1496,7 +1496,7 @@ class BNote extends AbstractBeccaEntity {parentNote.setContent(fixedContent);const noteService = require("../../services/notes");- noteService.asyncPostProcessContent(parentNote, fixedContent);+ noteService.asyncPostProcessContent(parentNote, fixedContent); // to mark an unused attachment for deletionthis.deleteNote();diff --git a/src/services/image.js b/src/services/image.jsindex a6b08a4d56..de71493f3d 100644--- a/src/services/image.js+++ b/src/services/image.js@@ -142,15 +142,21 @@ function saveImageToAttachment(noteId, uploadBuffer, originalName, shrinkImageSwconst fileName = sanitizeFilename(originalName);const note = becca.getNoteOrThrow(noteId);- const attachment = note.saveAttachment({+ let attachment = note.saveAttachment({role: 'image',mime: 'unknown',title: fileName});+ const noteService = require("../services/notes");+ noteService.asyncPostProcessContent(note, note.getContent()); // to mark an unused attachment for deletion+// resizing images asynchronously since JIMP does not support sync operationprocessImage(uploadBuffer, originalName, shrinkImageSwitch).then(({buffer, imageFormat}) => {sql.transactional(() => {+ // re-read, might be changed in the meantime+ attachment = becca.getAttachmentOrThrow(attachment.attachmentId);+attachment.mime = getImageMimeFromExtension(imageFormat.ext);if (!originalName.includes(".")) {