mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-05-02 20:43:58 +00:00
fixed loading keys in redis
This commit is contained in:
@@ -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];
|
const item = tree.dirsByKey[root];
|
||||||
if (!item.isExpanded) {
|
if (!item.isExpanded) {
|
||||||
return false;
|
return false;
|
||||||
@@ -185,7 +185,11 @@ function addFlatItems(tree: DbKeysTreeModel, root: string, res: DbKeysNodeModel[
|
|||||||
for (const child of children) {
|
for (const child of children) {
|
||||||
res.push(child);
|
res.push(child);
|
||||||
if (child.type == 'dir') {
|
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]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,11 +17,24 @@
|
|||||||
export let model: DbKeysTreeModel;
|
export let model: DbKeysTreeModel;
|
||||||
export let changeModel: DbKeysChangeModelFunction;
|
export let changeModel: DbKeysChangeModelFunction;
|
||||||
|
|
||||||
|
export let parentRoots = [];
|
||||||
|
|
||||||
$: items = model.childrenByKey[root] ?? [];
|
$: items = model.childrenByKey[root] ?? [];
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#each items as item}
|
{#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}
|
{/each}
|
||||||
|
|
||||||
{#if model.dirsByKey[root]?.shouldLoadNext}
|
{#if model.dirsByKey[root]?.shouldLoadNext}
|
||||||
|
|||||||
@@ -31,6 +31,7 @@
|
|||||||
export let item;
|
export let item;
|
||||||
export let indentLevel = 0;
|
export let indentLevel = 0;
|
||||||
export let filter;
|
export let filter;
|
||||||
|
export let parentRoots = [];
|
||||||
|
|
||||||
export let model: DbKeysTreeModel;
|
export let model: DbKeysTreeModel;
|
||||||
export let changeModel: DbKeysChangeModelFunction;
|
export let changeModel: DbKeysChangeModelFunction;
|
||||||
@@ -179,7 +180,7 @@
|
|||||||
{item.text}
|
{item.text}
|
||||||
</div> -->
|
</div> -->
|
||||||
|
|
||||||
{#if isExpanded}
|
{#if isExpanded && !parentRoots.includes(item.root)}
|
||||||
<DbKeysSubTree
|
<DbKeysSubTree
|
||||||
{conid}
|
{conid}
|
||||||
{database}
|
{database}
|
||||||
@@ -189,5 +190,6 @@
|
|||||||
{filter}
|
{filter}
|
||||||
{model}
|
{model}
|
||||||
{changeModel}
|
{changeModel}
|
||||||
|
{parentRoots}
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
@@ -260,7 +260,7 @@ const driver = {
|
|||||||
|
|
||||||
extractKeysFromLevel(dbhan, root, keys) {
|
extractKeysFromLevel(dbhan, root, keys) {
|
||||||
const prefix = root ? `${root}${dbhan.treeKeySeparator}` : '';
|
const prefix = root ? `${root}${dbhan.treeKeySeparator}` : '';
|
||||||
const rootSplit = _.compact(root.split(dbhan.treeKeySeparator));
|
const rootSplit = root == '' ? [] : root.split(dbhan.treeKeySeparator);
|
||||||
const res = {};
|
const res = {};
|
||||||
for (const key of keys) {
|
for (const key of keys) {
|
||||||
if (!key.startsWith(prefix)) continue;
|
if (!key.startsWith(prefix)) continue;
|
||||||
|
|||||||
Reference in New Issue
Block a user