fixed loading keys in redis

This commit is contained in:
SPRINX0\prochazka
2025-05-12 10:28:28 +02:00
parent 8c1b51b7e9
commit 541af0b77e
4 changed files with 24 additions and 5 deletions

View File

@@ -176,7 +176,7 @@ export function dbKeys_reloadFolder(tree: DbKeysTreeModel, root: string): DbKeys
};
}
function addFlatItems(tree: DbKeysTreeModel, root: string, res: DbKeysNodeModel[]) {
function addFlatItems(tree: DbKeysTreeModel, root: string, res: DbKeysNodeModel[], visitedRoots: string[] = []) {
const item = tree.dirsByKey[root];
if (!item.isExpanded) {
return false;
@@ -185,7 +185,11 @@ function addFlatItems(tree: DbKeysTreeModel, root: string, res: DbKeysNodeModel[
for (const child of children) {
res.push(child);
if (child.type == 'dir') {
addFlatItems(tree, child.root, res);
if (visitedRoots.includes(child.root)) {
console.warn('Redis: preventing infinite loop for root', child.root);
return false;
}
addFlatItems(tree, child.root, res, [...visitedRoots, root]);
}
}
}