mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
check the attachment after upload
This commit is contained in:
parent
cea54aecad
commit
30bcd1764a
@ -1496,7 +1496,7 @@ class BNote extends AbstractBeccaEntity {
|
|||||||
parentNote.setContent(fixedContent);
|
parentNote.setContent(fixedContent);
|
||||||
|
|
||||||
const noteService = require("../../services/notes");
|
const noteService = require("../../services/notes");
|
||||||
noteService.asyncPostProcessContent(parentNote, fixedContent);
|
noteService.asyncPostProcessContent(parentNote, fixedContent); // to mark an unused attachment for deletion
|
||||||
|
|
||||||
this.deleteNote();
|
this.deleteNote();
|
||||||
|
|
||||||
|
@ -142,15 +142,21 @@ function saveImageToAttachment(noteId, uploadBuffer, originalName, shrinkImageSw
|
|||||||
const fileName = sanitizeFilename(originalName);
|
const fileName = sanitizeFilename(originalName);
|
||||||
const note = becca.getNoteOrThrow(noteId);
|
const note = becca.getNoteOrThrow(noteId);
|
||||||
|
|
||||||
const attachment = note.saveAttachment({
|
let attachment = note.saveAttachment({
|
||||||
role: 'image',
|
role: 'image',
|
||||||
mime: 'unknown',
|
mime: 'unknown',
|
||||||
title: fileName
|
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 operation
|
// resizing images asynchronously since JIMP does not support sync operation
|
||||||
processImage(uploadBuffer, originalName, shrinkImageSwitch).then(({buffer, imageFormat}) => {
|
processImage(uploadBuffer, originalName, shrinkImageSwitch).then(({buffer, imageFormat}) => {
|
||||||
sql.transactional(() => {
|
sql.transactional(() => {
|
||||||
|
// re-read, might be changed in the meantime
|
||||||
|
attachment = becca.getAttachmentOrThrow(attachment.attachmentId);
|
||||||
|
|
||||||
attachment.mime = getImageMimeFromExtension(imageFormat.ext);
|
attachment.mime = getImageMimeFromExtension(imageFormat.ext);
|
||||||
|
|
||||||
if (!originalName.includes(".")) {
|
if (!originalName.includes(".")) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user