added checksum to note_attachment

This commit is contained in:
zadam
2023-01-24 16:55:48 +01:00
parent a7b103e07a
commit 3c57f08ef7
3 changed files with 18 additions and 6 deletions

View File

@@ -1442,17 +1442,22 @@ class BNote extends AbstractBeccaEntity {
* @returns {BNoteAttachment}
*/
saveNoteAttachment(name, mime, content) {
this.getNoteAttachments()
let noteAttachment = this.getNoteAttachmentByName(name);
const noteAttachment = new BNoteAttachment({
if (noteAttachment
&& noteAttachment.mime === mime
&& noteAttachment.contentCheckSum === noteAttachment.calculateCheckSum(content)) {
return noteAttachment; // no change
}
noteAttachment = new BNoteAttachment({
noteId: this.noteId,
name,
mime,
isProtected: this.isProtected
});
noteAttachment.save();
noteAttachment.setContent(content);
return noteAttachment;