don't save zero byte buffers as note revisions

This commit is contained in:
zadam 2020-10-05 23:56:59 +02:00
parent 8855f29a49
commit 8a435a2149

View file

@ -23,17 +23,17 @@ function protectNoteRevisions(note) {
/** /**
* @param {Note} note * @param {Note} note
* @return {NoteRevision} * @return {NoteRevision|null}
*/ */
function createNoteRevision(note) { function createNoteRevision(note) {
if (note.hasLabel("disableVersioning")) { if (note.hasLabel("disableVersioning")) {
return; return null;
} }
const content = note.getContent(); const content = note.getContent();
if (!content) { if (!content || (Buffer.isBuffer(content) && content.byteLength === 0)) {
return; return null;
} }
const contentMetadata = note.getContentMetadata(); const contentMetadata = note.getContentMetadata();