mirror of
				https://github.com/zadam/trilium.git
				synced 2025-11-04 13:39:01 +01:00 
			
		
		
		
	correctly respect label @disableVersioning
(cherry picked from commit dc063983ea736f338e1d01d0863ee6f5ae40b2ee)
This commit is contained in:
		
							parent
							
								
									e9454e4db7
								
							
						
					
					
						commit
						f740e52ebf
					
				@ -12,9 +12,7 @@ const imageminGifLossy = require('imagemin-giflossy');
 | 
				
			|||||||
const jimp = require('jimp');
 | 
					const jimp = require('jimp');
 | 
				
			||||||
const imageType = require('image-type');
 | 
					const imageType = require('image-type');
 | 
				
			||||||
const sanitizeFilename = require('sanitize-filename');
 | 
					const sanitizeFilename = require('sanitize-filename');
 | 
				
			||||||
const dateUtils = require('./date_utils');
 | 
					 | 
				
			||||||
const noteRevisionService = require('./note_revisions.js');
 | 
					const noteRevisionService = require('./note_revisions.js');
 | 
				
			||||||
const NoteRevision = require("../entities/note_revision");
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
async function processImage(uploadBuffer, originalName, shrinkImageSwitch) {
 | 
					async function processImage(uploadBuffer, originalName, shrinkImageSwitch) {
 | 
				
			||||||
    const origImageFormat = imageType(uploadBuffer);
 | 
					    const origImageFormat = imageType(uploadBuffer);
 | 
				
			||||||
 | 
				
			|||||||
@ -7,10 +7,6 @@ const dateUtils = require('../services/date_utils');
 | 
				
			|||||||
 * @param {Note} note
 | 
					 * @param {Note} note
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
async function protectNoteRevisions(note) {
 | 
					async function protectNoteRevisions(note) {
 | 
				
			||||||
    if (await note.hasLabel('disableVersioning')) {
 | 
					 | 
				
			||||||
        return;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    for (const revision of await note.getRevisions()) {
 | 
					    for (const revision of await note.getRevisions()) {
 | 
				
			||||||
        if (note.isProtected !== revision.isProtected) {
 | 
					        if (note.isProtected !== revision.isProtected) {
 | 
				
			||||||
            const content = await revision.getContent();
 | 
					            const content = await revision.getContent();
 | 
				
			||||||
@ -30,6 +26,10 @@ async function protectNoteRevisions(note) {
 | 
				
			|||||||
 * @return {NoteRevision}
 | 
					 * @return {NoteRevision}
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
async function createNoteRevision(note) {
 | 
					async function createNoteRevision(note) {
 | 
				
			||||||
 | 
					    if (await note.hasLabel("disableVersioning")) {
 | 
				
			||||||
 | 
					        return;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const noteRevision = await new NoteRevision({
 | 
					    const noteRevision = await new NoteRevision({
 | 
				
			||||||
        noteId: note.noteId,
 | 
					        noteId: note.noteId,
 | 
				
			||||||
        // title and text should be decrypted now
 | 
					        // title and text should be decrypted now
 | 
				
			||||||
 | 
				
			|||||||
@ -308,8 +308,7 @@ async function saveLinks(note, content) {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
async function saveNoteRevision(note) {
 | 
					async function saveNoteRevision(note) {
 | 
				
			||||||
    // files and images are immutable, they can't be updated
 | 
					    // files and images are versioned separately
 | 
				
			||||||
    // but we don't even version titles which is probably not correct
 | 
					 | 
				
			||||||
    if (note.type === 'file' || note.type === 'image' || await note.hasLabel('disableVersioning')) {
 | 
					    if (note.type === 'file' || note.type === 'image' || await note.hasLabel('disableVersioning')) {
 | 
				
			||||||
        return;
 | 
					        return;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user