Skip to content

Commit df85a5e

Browse files
committed
Merge branch 'stable'
# Conflicts: # src/routes/api/revisions.js # src/services/bulk_actions.js
2 parents c35167f + 0ac397e commit df85a5e

File tree

10 files changed

+40
-33
lines changed

10 files changed

+40
-33
lines changed

package-lock.json

Lines changed: 10 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "trilium",
33
"productName": "Trilium Notes",
44
"description": "Trilium Notes",
5-
"version": "0.62.2",
5+
"version": "0.62.4",
66
"license": "AGPL-3.0-only",
77
"main": "electron.js",
88
"bin": {
@@ -112,7 +112,7 @@
112112
},
113113
"devDependencies": {
114114
"cross-env": "7.0.3",
115-
"electron": "25.9.5",
115+
"electron": "25.9.8",
116116
"electron-builder": "24.6.4",
117117
"electron-packager": "17.1.2",
118118
"electron-rebuild": "3.2.9",

src/routes/api/revisions.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const cls = require('../../services/cls.js');
88
const path = require('path');
99
const becca = require('../../becca/becca.js');
1010
const blobService = require('../../services/blob.js');
11+
const eraseService = require("../../services/erase.js");
1112

1213
function getRevisionBlob(req) {
1314
const preview = req.query.preview === 'true';
@@ -88,11 +89,11 @@ function eraseAllRevisions(req) {
8889
const revisionIdsToErase = sql.getColumn('SELECT revisionId FROM revisions WHERE noteId = ?',
8990
[req.params.noteId]);
9091

91-
revisionService.eraseRevisions(revisionIdsToErase);
92+
eraseService.eraseRevisions(revisionIdsToErase);
9293
}
9394

9495
function eraseRevision(req) {
95-
revisionService.eraseRevisions([req.params.revisionId]);
96+
eraseService.eraseRevisions([req.params.revisionId]);
9697
}
9798

9899
function restoreRevision(req) {

src/services/build.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
module.exports = { buildDate:"2023-11-21T20:49:24+01:00", buildRevision: "e2b1421bf3d764ffe444a103c118e67d8c563673" };
1+
module.exports = { buildDate:"2023-12-07T00:03:59+01:00", buildRevision: "2e23c521c356c2305124f5df0f474532fa5f34ce" };

src/services/bulk_actions.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const becca = require('../becca/becca.js');
44
const cloningService = require('./cloning.js');
55
const branchService = require('./branches.js');
66
const utils = require('./utils.js');
7+
const eraseService = require("./erase.js");
78

89
const ACTION_HANDLERS = {
910
addLabel: (action, note) => {
@@ -18,7 +19,7 @@ const ACTION_HANDLERS = {
1819
note.deleteNote(deleteId);
1920
},
2021
deleteRevisions: (action, note) => {
21-
revisionService.eraseRevisions(note.getRevisions().map(rev => rev.revisionId));
22+
eraseService.eraseRevisions(note.getRevisions().map(rev => rev.revisionId));
2223
},
2324
deleteLabel: (action, note) => {
2425
for (const label of note.getOwnedLabels(action.labelName)) {

src/services/consistency_checks.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ class ConsistencyChecks {
467467
WHERE blobs.blobId IS NULL`,
468468
({revisionId, blobId}) => {
469469
if (this.autoFix) {
470-
revisionService.eraseRevisions([revisionId]);
470+
eraseService.eraseRevisions([revisionId]);
471471

472472
this.reloadNeeded = true;
473473

src/services/erase.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ function eraseNotes(noteIdsToErase) {
2929
const revisionIdsToErase = sql.getManyRows(`SELECT revisionId FROM revisions WHERE noteId IN (???)`, noteIdsToErase)
3030
.map(row => row.revisionId);
3131

32-
revisionService.eraseRevisions(revisionIdsToErase);
32+
eraseRevisions(revisionIdsToErase);
3333

3434
log.info(`Erased notes: ${JSON.stringify(noteIdsToErase)}`);
3535
}
@@ -79,6 +79,18 @@ function eraseAttachments(attachmentIdsToErase) {
7979
log.info(`Erased attachments: ${JSON.stringify(attachmentIdsToErase)}`);
8080
}
8181

82+
function eraseRevisions(revisionIdsToErase) {
83+
if (revisionIdsToErase.length === 0) {
84+
return;
85+
}
86+
87+
sql.executeMany(`DELETE FROM revisions WHERE revisionId IN (???)`, revisionIdsToErase);
88+
89+
setEntityChangesAsErased(sql.getManyRows(`SELECT * FROM entity_changes WHERE entityName = 'revisions' AND entityId IN (???)`, revisionIdsToErase));
90+
91+
log.info(`Removed revisions: ${JSON.stringify(revisionIdsToErase)}`);
92+
}
93+
8294
function eraseUnusedBlobs() {
8395
const unusedBlobIds = sql.getColumn(`
8496
SELECT blobs.blobId
@@ -184,5 +196,6 @@ module.exports = {
184196
eraseUnusedAttachmentsNow,
185197
eraseNotesWithDeleteId,
186198
eraseUnusedBlobs,
187-
eraseAttachments
199+
eraseAttachments,
200+
eraseRevisions
188201
};

src/services/revisions.js

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -46,18 +46,6 @@ function protectRevisions(note) {
4646
}
4747
}
4848

49-
function eraseRevisions(revisionIdsToErase) {
50-
if (revisionIdsToErase.length === 0) {
51-
return;
52-
}
53-
54-
log.info(`Removing revisions: ${JSON.stringify(revisionIdsToErase)}`);
55-
56-
sql.executeMany(`DELETE FROM revisions WHERE revisionId IN (???)`, revisionIdsToErase);
57-
sql.executeMany(`UPDATE entity_changes SET isErased = 1, utcDateChanged = '${dateUtils.utcNowDateTime()}' WHERE entityName = 'revisions' AND entityId IN (???)`, revisionIdsToErase);
58-
}
59-
6049
module.exports = {
61-
protectRevisions,
62-
eraseRevisions
50+
protectRevisions
6351
};

src/services/tree.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,9 @@ function sortNotesIfNeeded(parentNoteId) {
209209
function setNoteToParent(noteId, prefix, parentNoteId) {
210210
const parentNote = becca.getNote(parentNoteId);
211211

212-
if (!parentNote) {
213-
throw new Error(`Cannot move note to deleted parent note '${parentNoteId}'`);
212+
if (parentNoteId && !parentNote) {
213+
// null parentNoteId is a valid value
214+
throw new Error(`Cannot move note to deleted / missing parent note '${parentNoteId}'`);
214215
}
215216

216217
// case where there might be more such branches is ignored. It's expected there should be just one

src/services/utils.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ function isElectron() {
6363
}
6464

6565
function hash(text) {
66+
text = text.normalize();
67+
6668
return crypto.createHash('sha1').update(text).digest('base64');
6769
}
6870

0 commit comments

Comments
 (0)