Fixing the fixes
This commit is contained in:
@@ -129,7 +129,7 @@ _kb_id_by_name() {
|
|||||||
local kb_name="$1"
|
local kb_name="$1"
|
||||||
local json; json="$(_owui_get_kb_list)"
|
local json; json="$(_owui_get_kb_list)"
|
||||||
# Robust KB name resolver: Unicode/space-insensitive, prefers most recently updated
|
# Robust KB name resolver: Unicode/space-insensitive, prefers most recently updated
|
||||||
python3 - "$kb_name" <<'PY' || true
|
printf '%s' "$json" | python3 - "$kb_name" <<'PY' || true
|
||||||
import sys, json, unicodedata as ud
|
import sys, json, unicodedata as ud
|
||||||
|
|
||||||
def norm(s: str) -> str:
|
def norm(s: str) -> str:
|
||||||
@@ -378,6 +378,23 @@ else:
|
|||||||
print('', end='')
|
print('', end='')
|
||||||
PY
|
PY
|
||||||
<<<"$json")"
|
<<<"$json")"
|
||||||
|
# Fallback: if the list contains exactly one KB, use its id
|
||||||
|
if [ -z "$id" ]; then
|
||||||
|
id="$(printf '%s' "$json" | python3 - <<'PY' || true
|
||||||
|
import sys, json
|
||||||
|
raw=sys.stdin.read().strip()
|
||||||
|
try:
|
||||||
|
d=json.loads(raw)
|
||||||
|
except Exception:
|
||||||
|
print('', end=''); raise SystemExit(0)
|
||||||
|
items = d.get('data') if isinstance(d, dict) and isinstance(d.get('data'), list) else (d if isinstance(d, list) else [])
|
||||||
|
if isinstance(items, list) and len(items)==1:
|
||||||
|
print(items[0].get('id',''), end='')
|
||||||
|
else:
|
||||||
|
print('', end='')
|
||||||
|
PY
|
||||||
|
)"
|
||||||
|
fi
|
||||||
if [ -n "$id" ]; then
|
if [ -n "$id" ]; then
|
||||||
echo "[owui] resolved id for \"$name\": $id"
|
echo "[owui] resolved id for \"$name\": $id"
|
||||||
else
|
else
|
||||||
|
Reference in New Issue
Block a user