diff --git a/package.json b/package.json index 7f378b70b..73c6df5e6 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "trilium", "productName": "Trilium Notes", "description": "Trilium Notes", - "version": "0.39.4", + "version": "0.39.5", "license": "AGPL-3.0-only", "main": "electron.js", "bin": { diff --git a/src/public/javascripts/services/protected_session.js b/src/public/javascripts/services/protected_session.js index 977ca9bfd..168ff3b27 100644 --- a/src/public/javascripts/services/protected_session.js +++ b/src/public/javascripts/services/protected_session.js @@ -42,6 +42,8 @@ async function setupProtectedSession(password) { return; } + $("#container").addClass('protected-session-active'); + protectedSessionHolder.setProtectedSessionId(response.protectedSessionId); protectedSessionHolder.touchProtectedSession(); diff --git a/src/services/build.js b/src/services/build.js index a7fd163b3..1d246ab49 100644 --- a/src/services/build.js +++ b/src/services/build.js @@ -1 +1 @@ -module.exports = { buildDate:"2020-01-04T22:01:20+01:00", buildRevision: "3b8b4da149fbc1b17d09253693823f5135a55f2e" }; +module.exports = { buildDate:"2020-01-08T21:01:24+01:00", buildRevision: "2b69abf8ab2241f01cd38b31308e54b9faaa74d5" }; diff --git a/src/services/consistency_checks.js b/src/services/consistency_checks.js index 9c8a17dae..2a2911b3f 100644 --- a/src/services/consistency_checks.js +++ b/src/services/consistency_checks.js @@ -18,18 +18,6 @@ class ConsistencyChecks { this.fixedIssues = false; } - async findIssues(query, errorCb) { - const results = await sql.getRows(query); - - for (const res of results) { - logError(errorCb(res)); - - this.unrecoveredConsistencyErrors = true; - } - - return results; - } - async findAndFixIssues(query, fixerCb) { const results = await sql.getRows(query); @@ -175,13 +163,6 @@ class ConsistencyChecks { logError(`Relation ${attributeId} references missing note ${noteId}`) } }); - - await this.findIssues(` - SELECT noteRevisionId, note_revisions.noteId - FROM note_revisions - LEFT JOIN notes USING (noteId) - WHERE notes.noteId IS NULL`, - ({noteRevisionId, noteId}) => `Note revision ${noteRevisionId} references missing note ${noteId}`); } async findExistencyIssues() { @@ -335,13 +316,22 @@ class ConsistencyChecks { } }); - await this.findIssues(` + await this.findAndFixIssues(` SELECT noteId FROM notes JOIN note_contents USING (noteId) WHERE isErased = 1 AND content IS NOT NULL`, - ({noteId}) => `Note ${noteId} content is not null even though the note is erased`); + async ({noteId}) => { + if (this.autoFix) { + await sql.execute(`UPDATE note_contents SET content = NULL WHERE noteId = ?`, [noteId]); + + logFix(`Note ${noteId} content has been set to null since the note is erased`); + } + else { + logError(`Note ${noteId} content is not null even though the note is erased`); + } + }); await this.findAndFixIssues(` SELECT noteId, noteRevisionId @@ -398,20 +388,40 @@ class ConsistencyChecks { } }); - await this.findIssues(` + await this.findAndFixIssues(` SELECT noteRevisionId FROM note_revisions JOIN note_revision_contents USING (noteRevisionId) WHERE isErased = 1 AND content IS NOT NULL`, - ({noteRevisionId}) => `Note revision ${noteRevisionId} content is not null even though the note revision is erased`); + async ({noteRevisionId}) => { + if (this.autoFix) { + await sql.execute(`UPDATE note_revision_contents SET content = NULL WHERE noteRevisionId = ?`, [noteRevisionId]); - await this.findIssues(` + logFix(`Note revision ${noteRevisionId} content was set to null since the note revision is erased`); + } + else { + logError(`Note revision ${noteRevisionId} content is not null even though the note revision is erased`); + } + }); + + await this.findAndFixIssues(` SELECT noteId FROM notes WHERE isErased = 1 AND isDeleted = 0`, - ({noteId}) => `Note ${noteId} is not deleted even though it is erased`); + async ({noteId}) => { + if (this.autoFix) { + const note = await repository.getNote(noteId); + note.isDeleted = true; + await note.save(); + + logFix(`Note ${noteId} was set to deleted since it is erased`); + } + else { + logError(`Note ${noteId} is not deleted even though it is erased`); + } + }); await this.findAndFixIssues(` SELECT parentNoteId diff --git a/src/services/parse_filters.js b/src/services/parse_filters.js index 892e83579..86905cc60 100644 --- a/src/services/parse_filters.js +++ b/src/services/parse_filters.js @@ -1,6 +1,6 @@ const dayjs = require("dayjs"); -const filterRegex = /(\b(AND|OR)\s+)?@(!?)([\p{L}\p{Number}_]+|"[^"]+")\s*((=|!=|<|<=|>|>=|!?\*=|!?=\*|!?\*=\*)\s*(\S+|"[^"]+"))?/igu; +const filterRegex = /(\b(AND|OR)\s+)?@(!?)([\p{L}\p{Number}_]+|"[^"]+")\s*((=|!=|<|<=|>|>=|!?\*=|!?=\*|!?\*=\*)\s*([^\s=*]+|"[^"]+"))?/igu; const smartValueRegex = /^(NOW|TODAY|WEEK|MONTH|YEAR) *([+\-] *\d+)?$/i; function calculateSmartValue(v) {