mirror of
https://github.com/zadam/trilium.git
synced 2025-01-17 20:48:12 +08:00
better logging for un/protect errors
This commit is contained in:
parent
31876d2cf9
commit
33571e0ef3
3 changed files with 28 additions and 13 deletions
|
@ -650,7 +650,7 @@ class ConsistencyChecks {
|
||||||
// root branch should always be expanded
|
// root branch should always be expanded
|
||||||
sql.execute("UPDATE branches SET isExpanded = 1 WHERE branchId = 'root'");
|
sql.execute("UPDATE branches SET isExpanded = 1 WHERE branchId = 'root'");
|
||||||
|
|
||||||
if (this.unrecoveredConsistencyErrors) {
|
if (!this.unrecoveredConsistencyErrors) {
|
||||||
// we run this only if basic checks passed since this assumes basic data consistency
|
// we run this only if basic checks passed since this assumes basic data consistency
|
||||||
|
|
||||||
this.checkTreeCycles();
|
this.checkTreeCycles();
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
const NoteRevision = require('../entities/note_revision');
|
const NoteRevision = require('../entities/note_revision');
|
||||||
const dateUtils = require('../services/date_utils');
|
const dateUtils = require('../services/date_utils');
|
||||||
|
const log = require('../services/log');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Note} note
|
* @param {Note} note
|
||||||
|
@ -9,14 +10,21 @@ const dateUtils = require('../services/date_utils');
|
||||||
function protectNoteRevisions(note) {
|
function protectNoteRevisions(note) {
|
||||||
for (const revision of note.getRevisions()) {
|
for (const revision of note.getRevisions()) {
|
||||||
if (note.isProtected !== revision.isProtected) {
|
if (note.isProtected !== revision.isProtected) {
|
||||||
const content = revision.getContent();
|
try {
|
||||||
|
const content = revision.getContent();
|
||||||
|
|
||||||
revision.isProtected = note.isProtected;
|
revision.isProtected = note.isProtected;
|
||||||
|
|
||||||
// this will force de/encryption
|
// this will force de/encryption
|
||||||
revision.setContent(content);
|
revision.setContent(content);
|
||||||
|
|
||||||
revision.save();
|
revision.save();
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
log.error("Could not un/protect note revision ID = " + revision.noteRevisionId);
|
||||||
|
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -185,18 +185,25 @@ function protectNoteRecursively(note, protect, includingSubTree, taskContext) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function protectNote(note, protect) {
|
function protectNote(note, protect) {
|
||||||
if (protect !== note.isProtected) {
|
try {
|
||||||
const content = note.getContent();
|
if (protect !== note.isProtected) {
|
||||||
|
const content = note.getContent();
|
||||||
|
|
||||||
note.isProtected = protect;
|
note.isProtected = protect;
|
||||||
|
|
||||||
// this will force de/encryption
|
// this will force de/encryption
|
||||||
note.setContent(content);
|
note.setContent(content);
|
||||||
|
|
||||||
note.save();
|
note.save();
|
||||||
|
}
|
||||||
|
|
||||||
|
noteRevisionService.protectNoteRevisions(note);
|
||||||
}
|
}
|
||||||
|
catch (e) {
|
||||||
|
log.error("Could not un/protect note ID = " + note.noteId);
|
||||||
|
|
||||||
noteRevisionService.protectNoteRevisions(note);
|
throw e;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function findImageLinks(content, foundLinks) {
|
function findImageLinks(content, foundLinks) {
|
||||||
|
|
Loading…
Reference in a new issue