mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
prevent cycles in resolving the notepath, fixes #1730
This commit is contained in:
parent
a33ac65fdf
commit
09e9ac4d00
2
package-lock.json
generated
2
package-lock.json
generated
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "trilium",
|
||||
"version": "0.46.2-beta",
|
||||
"version": "0.46.3-beta",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
@ -254,22 +254,39 @@ class NoteShort {
|
||||
return noteAttributeCache.attributes[this.noteId];
|
||||
}
|
||||
|
||||
getAllNotePaths() {
|
||||
getAllNotePaths(encounteredNoteIds = null) {
|
||||
if (this.noteId === 'root') {
|
||||
return [['root']];
|
||||
}
|
||||
|
||||
if (!encounteredNoteIds) {
|
||||
encounteredNoteIds = new Set();
|
||||
}
|
||||
|
||||
encounteredNoteIds.add(this.noteId);
|
||||
|
||||
const parentNotes = this.getParentNotes();
|
||||
let paths;
|
||||
|
||||
if (parentNotes.length === 1) { // optimization for the most common case
|
||||
paths = parentNotes[0].getAllNotePaths();
|
||||
if (encounteredNoteIds.has(parentNotes[0].noteId)) {
|
||||
return [];
|
||||
}
|
||||
else {
|
||||
paths = parentNotes[0].getAllNotePaths(encounteredNoteIds);
|
||||
}
|
||||
}
|
||||
else {
|
||||
paths = [];
|
||||
|
||||
for (const parentNote of parentNotes) {
|
||||
paths.push(...parentNote.getAllNotePaths());
|
||||
if (encounteredNoteIds.has(parentNote.noteId)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const newSet = new Set(encounteredNoteIds);
|
||||
|
||||
paths.push(...parentNote.getAllNotePaths(newSet));
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user