better logging for un/protect errors

This commit is contained in:
zadam 2020-12-09 22:49:55 +01:00
parent 31876d2cf9
commit 33571e0ef3
3 changed files with 28 additions and 13 deletions

View file

@ -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();

View file

@ -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,6 +10,7 @@ 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) {
try {
const content = revision.getContent(); const content = revision.getContent();
revision.isProtected = note.isProtected; revision.isProtected = note.isProtected;
@ -18,6 +20,12 @@ function protectNoteRevisions(note) {
revision.save(); revision.save();
} }
catch (e) {
log.error("Could not un/protect note revision ID = " + revision.noteRevisionId);
throw e;
}
}
} }
} }

View file

@ -185,6 +185,7 @@ function protectNoteRecursively(note, protect, includingSubTree, taskContext) {
} }
function protectNote(note, protect) { function protectNote(note, protect) {
try {
if (protect !== note.isProtected) { if (protect !== note.isProtected) {
const content = note.getContent(); const content = note.getContent();
@ -198,6 +199,12 @@ function protectNote(note, protect) {
noteRevisionService.protectNoteRevisions(note); noteRevisionService.protectNoteRevisions(note);
} }
catch (e) {
log.error("Could not un/protect note ID = " + note.noteId);
throw e;
}
}
function findImageLinks(content, foundLinks) { function findImageLinks(content, foundLinks) {
const re = /src="[^"]*api\/images\/([a-zA-Z0-9]+)\//g; const re = /src="[^"]*api\/images\/([a-zA-Z0-9]+)\//g;