mirror of
https://github.com/zadam/trilium.git
synced 2024-11-10 17:13:45 +08:00
Merge branch 'stable'
# Conflicts: # src/routes/api/revisions.js # src/services/bulk_actions.js
This commit is contained in:
commit
df85a5eee4
10 changed files with 40 additions and 33 deletions
19
package-lock.json
generated
19
package-lock.json
generated
|
@ -1,11 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "trilium",
|
"name": "trilium",
|
||||||
"version": "0.62.2",
|
"version": "0.62.3",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"version": "0.62.2",
|
"name": "trilium",
|
||||||
|
"version": "0.62.3",
|
||||||
"hasInstallScript": true,
|
"hasInstallScript": true,
|
||||||
"license": "AGPL-3.0-only",
|
"license": "AGPL-3.0-only",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
@ -88,7 +89,7 @@
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"cross-env": "7.0.3",
|
"cross-env": "7.0.3",
|
||||||
"electron": "25.9.5",
|
"electron": "25.9.8",
|
||||||
"electron-builder": "24.6.4",
|
"electron-builder": "24.6.4",
|
||||||
"electron-packager": "17.1.2",
|
"electron-packager": "17.1.2",
|
||||||
"electron-rebuild": "3.2.9",
|
"electron-rebuild": "3.2.9",
|
||||||
|
@ -5101,9 +5102,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/electron": {
|
"node_modules/electron": {
|
||||||
"version": "25.9.5",
|
"version": "25.9.8",
|
||||||
"resolved": "https://registry.npmjs.org/electron/-/electron-25.9.5.tgz",
|
"resolved": "https://registry.npmjs.org/electron/-/electron-25.9.8.tgz",
|
||||||
"integrity": "sha512-gM7GXUSd3JVRcYbBnNOtZeNnE5MCJjtZTT8QyIxJvpQ0Dh9dz3hTuEL62dOwnMFW/l47ACQ6es/8qi01P4QGZA==",
|
"integrity": "sha512-PGgp6PH46QVENHuAHc2NT1Su8Q1qov7qIl2jI5tsDpTibwV2zD8539AeWBQySeBU4dhbj9onIl7+1bXQ0wefBg==",
|
||||||
"hasInstallScript": true,
|
"hasInstallScript": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@electron/get": "^2.0.0",
|
"@electron/get": "^2.0.0",
|
||||||
|
@ -19123,9 +19124,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"electron": {
|
"electron": {
|
||||||
"version": "25.9.5",
|
"version": "25.9.8",
|
||||||
"resolved": "https://registry.npmjs.org/electron/-/electron-25.9.5.tgz",
|
"resolved": "https://registry.npmjs.org/electron/-/electron-25.9.8.tgz",
|
||||||
"integrity": "sha512-gM7GXUSd3JVRcYbBnNOtZeNnE5MCJjtZTT8QyIxJvpQ0Dh9dz3hTuEL62dOwnMFW/l47ACQ6es/8qi01P4QGZA==",
|
"integrity": "sha512-PGgp6PH46QVENHuAHc2NT1Su8Q1qov7qIl2jI5tsDpTibwV2zD8539AeWBQySeBU4dhbj9onIl7+1bXQ0wefBg==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"@electron/get": "^2.0.0",
|
"@electron/get": "^2.0.0",
|
||||||
"@types/node": "^18.11.18",
|
"@types/node": "^18.11.18",
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
"name": "trilium",
|
"name": "trilium",
|
||||||
"productName": "Trilium Notes",
|
"productName": "Trilium Notes",
|
||||||
"description": "Trilium Notes",
|
"description": "Trilium Notes",
|
||||||
"version": "0.62.2",
|
"version": "0.62.4",
|
||||||
"license": "AGPL-3.0-only",
|
"license": "AGPL-3.0-only",
|
||||||
"main": "electron.js",
|
"main": "electron.js",
|
||||||
"bin": {
|
"bin": {
|
||||||
|
@ -112,7 +112,7 @@
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"cross-env": "7.0.3",
|
"cross-env": "7.0.3",
|
||||||
"electron": "25.9.5",
|
"electron": "25.9.8",
|
||||||
"electron-builder": "24.6.4",
|
"electron-builder": "24.6.4",
|
||||||
"electron-packager": "17.1.2",
|
"electron-packager": "17.1.2",
|
||||||
"electron-rebuild": "3.2.9",
|
"electron-rebuild": "3.2.9",
|
||||||
|
|
|
@ -8,6 +8,7 @@ const cls = require('../../services/cls.js');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const becca = require('../../becca/becca.js');
|
const becca = require('../../becca/becca.js');
|
||||||
const blobService = require('../../services/blob.js');
|
const blobService = require('../../services/blob.js');
|
||||||
|
const eraseService = require("../../services/erase.js");
|
||||||
|
|
||||||
function getRevisionBlob(req) {
|
function getRevisionBlob(req) {
|
||||||
const preview = req.query.preview === 'true';
|
const preview = req.query.preview === 'true';
|
||||||
|
@ -88,11 +89,11 @@ function eraseAllRevisions(req) {
|
||||||
const revisionIdsToErase = sql.getColumn('SELECT revisionId FROM revisions WHERE noteId = ?',
|
const revisionIdsToErase = sql.getColumn('SELECT revisionId FROM revisions WHERE noteId = ?',
|
||||||
[req.params.noteId]);
|
[req.params.noteId]);
|
||||||
|
|
||||||
revisionService.eraseRevisions(revisionIdsToErase);
|
eraseService.eraseRevisions(revisionIdsToErase);
|
||||||
}
|
}
|
||||||
|
|
||||||
function eraseRevision(req) {
|
function eraseRevision(req) {
|
||||||
revisionService.eraseRevisions([req.params.revisionId]);
|
eraseService.eraseRevisions([req.params.revisionId]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function restoreRevision(req) {
|
function restoreRevision(req) {
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
module.exports = { buildDate:"2023-11-21T20:49:24+01:00", buildRevision: "e2b1421bf3d764ffe444a103c118e67d8c563673" };
|
module.exports = { buildDate:"2023-12-07T00:03:59+01:00", buildRevision: "2e23c521c356c2305124f5df0f474532fa5f34ce" };
|
||||||
|
|
|
@ -4,6 +4,7 @@ const becca = require('../becca/becca.js');
|
||||||
const cloningService = require('./cloning.js');
|
const cloningService = require('./cloning.js');
|
||||||
const branchService = require('./branches.js');
|
const branchService = require('./branches.js');
|
||||||
const utils = require('./utils.js');
|
const utils = require('./utils.js');
|
||||||
|
const eraseService = require("./erase.js");
|
||||||
|
|
||||||
const ACTION_HANDLERS = {
|
const ACTION_HANDLERS = {
|
||||||
addLabel: (action, note) => {
|
addLabel: (action, note) => {
|
||||||
|
@ -18,7 +19,7 @@ const ACTION_HANDLERS = {
|
||||||
note.deleteNote(deleteId);
|
note.deleteNote(deleteId);
|
||||||
},
|
},
|
||||||
deleteRevisions: (action, note) => {
|
deleteRevisions: (action, note) => {
|
||||||
revisionService.eraseRevisions(note.getRevisions().map(rev => rev.revisionId));
|
eraseService.eraseRevisions(note.getRevisions().map(rev => rev.revisionId));
|
||||||
},
|
},
|
||||||
deleteLabel: (action, note) => {
|
deleteLabel: (action, note) => {
|
||||||
for (const label of note.getOwnedLabels(action.labelName)) {
|
for (const label of note.getOwnedLabels(action.labelName)) {
|
||||||
|
|
|
@ -467,7 +467,7 @@ class ConsistencyChecks {
|
||||||
WHERE blobs.blobId IS NULL`,
|
WHERE blobs.blobId IS NULL`,
|
||||||
({revisionId, blobId}) => {
|
({revisionId, blobId}) => {
|
||||||
if (this.autoFix) {
|
if (this.autoFix) {
|
||||||
revisionService.eraseRevisions([revisionId]);
|
eraseService.eraseRevisions([revisionId]);
|
||||||
|
|
||||||
this.reloadNeeded = true;
|
this.reloadNeeded = true;
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ function eraseNotes(noteIdsToErase) {
|
||||||
const revisionIdsToErase = sql.getManyRows(`SELECT revisionId FROM revisions WHERE noteId IN (???)`, noteIdsToErase)
|
const revisionIdsToErase = sql.getManyRows(`SELECT revisionId FROM revisions WHERE noteId IN (???)`, noteIdsToErase)
|
||||||
.map(row => row.revisionId);
|
.map(row => row.revisionId);
|
||||||
|
|
||||||
revisionService.eraseRevisions(revisionIdsToErase);
|
eraseRevisions(revisionIdsToErase);
|
||||||
|
|
||||||
log.info(`Erased notes: ${JSON.stringify(noteIdsToErase)}`);
|
log.info(`Erased notes: ${JSON.stringify(noteIdsToErase)}`);
|
||||||
}
|
}
|
||||||
|
@ -79,6 +79,18 @@ function eraseAttachments(attachmentIdsToErase) {
|
||||||
log.info(`Erased attachments: ${JSON.stringify(attachmentIdsToErase)}`);
|
log.info(`Erased attachments: ${JSON.stringify(attachmentIdsToErase)}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function eraseRevisions(revisionIdsToErase) {
|
||||||
|
if (revisionIdsToErase.length === 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
sql.executeMany(`DELETE FROM revisions WHERE revisionId IN (???)`, revisionIdsToErase);
|
||||||
|
|
||||||
|
setEntityChangesAsErased(sql.getManyRows(`SELECT * FROM entity_changes WHERE entityName = 'revisions' AND entityId IN (???)`, revisionIdsToErase));
|
||||||
|
|
||||||
|
log.info(`Removed revisions: ${JSON.stringify(revisionIdsToErase)}`);
|
||||||
|
}
|
||||||
|
|
||||||
function eraseUnusedBlobs() {
|
function eraseUnusedBlobs() {
|
||||||
const unusedBlobIds = sql.getColumn(`
|
const unusedBlobIds = sql.getColumn(`
|
||||||
SELECT blobs.blobId
|
SELECT blobs.blobId
|
||||||
|
@ -184,5 +196,6 @@ module.exports = {
|
||||||
eraseUnusedAttachmentsNow,
|
eraseUnusedAttachmentsNow,
|
||||||
eraseNotesWithDeleteId,
|
eraseNotesWithDeleteId,
|
||||||
eraseUnusedBlobs,
|
eraseUnusedBlobs,
|
||||||
eraseAttachments
|
eraseAttachments,
|
||||||
|
eraseRevisions
|
||||||
};
|
};
|
||||||
|
|
|
@ -46,18 +46,6 @@ function protectRevisions(note) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function eraseRevisions(revisionIdsToErase) {
|
|
||||||
if (revisionIdsToErase.length === 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
log.info(`Removing revisions: ${JSON.stringify(revisionIdsToErase)}`);
|
|
||||||
|
|
||||||
sql.executeMany(`DELETE FROM revisions WHERE revisionId IN (???)`, revisionIdsToErase);
|
|
||||||
sql.executeMany(`UPDATE entity_changes SET isErased = 1, utcDateChanged = '${dateUtils.utcNowDateTime()}' WHERE entityName = 'revisions' AND entityId IN (???)`, revisionIdsToErase);
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
protectRevisions,
|
protectRevisions
|
||||||
eraseRevisions
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -209,8 +209,9 @@ function sortNotesIfNeeded(parentNoteId) {
|
||||||
function setNoteToParent(noteId, prefix, parentNoteId) {
|
function setNoteToParent(noteId, prefix, parentNoteId) {
|
||||||
const parentNote = becca.getNote(parentNoteId);
|
const parentNote = becca.getNote(parentNoteId);
|
||||||
|
|
||||||
if (!parentNote) {
|
if (parentNoteId && !parentNote) {
|
||||||
throw new Error(`Cannot move note to deleted parent note '${parentNoteId}'`);
|
// null parentNoteId is a valid value
|
||||||
|
throw new Error(`Cannot move note to deleted / missing parent note '${parentNoteId}'`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// case where there might be more such branches is ignored. It's expected there should be just one
|
// case where there might be more such branches is ignored. It's expected there should be just one
|
||||||
|
|
|
@ -63,6 +63,8 @@ function isElectron() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function hash(text) {
|
function hash(text) {
|
||||||
|
text = text.normalize();
|
||||||
|
|
||||||
return crypto.createHash('sha1').update(text).digest('base64');
|
return crypto.createHash('sha1').update(text).digest('base64');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue