Skip to content

Build your personal knowledge base with Trilium Notes

link fixes

zadamc9d0b8cc40d9
diff --git a/src/public/javascripts/widgets/link_map.js b/src/public/javascripts/widgets/link_map.js
index 2bef87030f..a5f78107dc 100644
--- a/src/public/javascripts/widgets/link_map.js
+++ b/src/public/javascripts/widgets/link_map.js
@@ -55,13 +55,11 @@ class LinkMapWidget extends StandardWidget {
async loadNotesAndRelations() {
this.cleanup();
- const linkTypes = [ "hyper", "image", "relation", "relation-map" ];
const maxNotes = 50;
const currentNoteId = this.ctx.note.noteId;
const links = await server.post(`notes/${currentNoteId}/link-map`, {
- linkTypes,
maxNotes,
maxDepth: 1
});
diff --git a/src/routes/api/link_map.js b/src/routes/api/link_map.js
index 4ea882f23f..f5704409bb 100644
--- a/src/routes/api/link_map.js
+++ b/src/routes/api/link_map.js
@@ -9,12 +9,12 @@ async function getRelations(noteIds, relationNames) {
WHERE (noteId IN (???) OR value IN (???))
AND type = 'relation'
AND isDeleted = 0
- `, Array.from(noteIds))).filter(l => relationNames.includes(l.name));
+ `, Array.from(noteIds)));
}
async function getLinkMap(req) {
const {noteId} = req.params;
- const {relationNames, maxNotes, maxDepth} = req.body;
+ const {maxNotes, maxDepth} = req.body;
let noteIds = new Set([noteId]);
let relations;
@@ -22,7 +22,7 @@ async function getLinkMap(req) {
let depth = 0;
while (true) {
- relations = await getRelations(noteIds, relationNames);
+ relations = await getRelations(noteIds);
if (depth === maxDepth) {
break;
diff --git a/src/services/consistency_checks.js b/src/services/consistency_checks.js
index e326264fab..cd8b6a8f9e 100644
--- a/src/services/consistency_checks.js
+++ b/src/services/consistency_checks.js
@@ -115,18 +115,6 @@ async function findBrokenReferenceIssues() {
AND attributes.value != '' AND notes.noteId IS NULL`,
({attributeId, noteId}) => `Relation ${attributeId} references missing note ${noteId}`);
- await findIssues(`
- SELECT linkId, links.noteId
- FROM links LEFT JOIN notes USING(noteId)
- WHERE links.isDeleted = 0 AND notes.noteId IS NULL`,
- ({linkId, noteId}) => `Link ${linkId} references missing source note ${noteId}`);
-
- await findIssues(`
- SELECT linkId, links.noteId
- FROM links LEFT JOIN notes ON notes.noteId = links.targetNoteId
- WHERE links.isDeleted = 0 AND notes.noteId IS NULL`,
- ({linkId, noteId}) => `Link ${linkId} references missing target note ${noteId}`);
-
await findIssues(`
SELECT noteRevisionId, note_revisions.noteId
FROM note_revisions LEFT JOIN notes USING(noteId)
@@ -135,7 +123,7 @@ async function findBrokenReferenceIssues() {
}
async function findExistencyIssues() {
- // principle for fixing inconsistencies is that if the note itself is deleted (isDeleted=true) then all related entities should be also deleted (branches, links, attributes)
+ // principle for fixing inconsistencies is that if the note itself is deleted (isDeleted=true) then all related entities should be also deleted (branches, attributes)
// but if note is not deleted, then at least one branch should exist.
// the order here is important - first we might need to delete inconsistent branches and after that
@@ -315,48 +303,6 @@ async function findLogicIssues() {
logFix(`Removed attribute ${attributeId} because target note ${targetNoteId} is also deleted.`);
});
-
- await findIssues(`
- SELECT linkId
- FROM links
- WHERE type NOT IN ('image', 'hyper', 'relation-map')`,
- ({linkId, type}) => `Link ${linkId} has invalid type '${type}'`);
-
- await findAndFixIssues(`
- SELECT
- linkId,
- links.noteId AS sourceNoteId
- FROM
- links
- JOIN notes AS sourceNote ON sourceNote.noteId = links.noteId
- WHERE
- links.isDeleted = 0
- AND sourceNote.isDeleted = 1`,
- async ({linkId, sourceNoteId}) => {
- const link = await repository.getLink(linkId);
- link.isDeleted = true;
- await link.save();
-
- logFix(`Removed link ${linkId} because source note ${sourceNoteId} is also deleted.`);
- });
-
- await findAndFixIssues(`
- SELECT
- linkId,
- links.targetNoteId
- FROM
- links
- JOIN notes AS targetNote ON targetNote.noteId = links.targetNoteId
- WHERE
- links.isDeleted = 0
- AND targetNote.isDeleted = 1`,
- async ({linkId, targetNoteId}) => {
- const link = await repository.getLink(linkId);
- link.isDeleted = true;
- await link.save();
-
- logFix(`Removed link ${linkId} because target note ${targetNoteId} is also deleted.`);
- });
}
async function runSyncRowChecks(entityName, key) {