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 undelete attachments
zadam806062c8d1a0
diff --git a/src/services/notes.js b/src/services/notes.jsindex d026949d97..cae0aff6b1 100644--- a/src/services/notes.js+++ b/src/services/notes.js@@ -15,6 +15,7 @@ const becca = require('../becca/becca');const BBranch = require('../becca/entities/bbranch');const BNote = require('../becca/entities/bnote');const BAttribute = require('../becca/entities/battribute');+const BAttachment = require("../becca/entities/battachment");const dayjs = require("dayjs");const htmlSanitizer = require("./html_sanitizer");const ValidationError = require("../errors/validation_error");@@ -810,6 +811,16 @@ function undeleteBranch(branchId, deleteId, taskContext) {new BAttribute(attributeRow).save({skipValidation: true});}+ const attachmentRows = sql.getRows(`+ SELECT * FROM attachments+ WHERE isDeleted = 1+ AND deleteId = ?+ AND ownerId = ?`, [deleteId, noteRow.noteId]);++ for (const attachmentRow of attachmentRows) {+ new BAttachment(attachmentRow).save();+ }+const childBranchIds = sql.getColumn(`SELECT branches.branchIdFROM branches