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]);
}
}
}

View File

@@ -17,11 +17,24 @@
export let model: DbKeysTreeModel;
export let changeModel: DbKeysChangeModelFunction;
export let parentRoots = [];
$: items = model.childrenByKey[root] ?? [];
</script>
{#each items as item}
<DbKeysTreeNode {conid} {database} {root} {connection} {item} {filter} {indentLevel} {model} {changeModel} />
<DbKeysTreeNode
{conid}
{database}
{root}
{connection}
{item}
{filter}
{indentLevel}
{model}
{changeModel}
parentRoots={[...parentRoots, root]}
/>
{/each}
{#if model.dirsByKey[root]?.shouldLoadNext}

View File

@@ -31,6 +31,7 @@
export let item;
export let indentLevel = 0;
export let filter;
export let parentRoots = [];
export let model: DbKeysTreeModel;
export let changeModel: DbKeysChangeModelFunction;
@@ -179,7 +180,7 @@
{item.text}
</div> -->
{#if isExpanded}
{#if isExpanded && !parentRoots.includes(item.root)}
<DbKeysSubTree
{conid}
{database}
@@ -189,5 +190,6 @@
{filter}
{model}
{changeModel}
{parentRoots}
/>
{/if}

View File

@@ -260,7 +260,7 @@ const driver = {
extractKeysFromLevel(dbhan, root, keys) {
const prefix = root ? `${root}${dbhan.treeKeySeparator}` : '';
const rootSplit = _.compact(root.split(dbhan.treeKeySeparator));
const rootSplit = root == '' ? [] : root.split(dbhan.treeKeySeparator);
const res = {};
for (const key of keys) {
if (!key.startsWith(prefix)) continue;