refactor: direct roster lookups in cmd_role and cmd_who
cmd_role's TMUX-socket match and cmd_who's --socket branch each walked every roster via roster_list to find the one record they already knew the path to. Read that record directly instead. roster_read still validates the dir basename and ownership, so a non-party socket falls through to cmd_role's existing fallback loop.
This commit is contained in:
parent
fb92ea1ae7
commit
c28101e2e8
1 changed files with 9 additions and 7 deletions
16
party
16
party
|
|
@ -1648,7 +1648,7 @@ cmd_who() {
|
||||||
# roster_read overwrites these with the same values on success.
|
# roster_read overwrites these with the same values on success.
|
||||||
RR_HOST_USER="${stripped%%:*}"
|
RR_HOST_USER="${stripped%%:*}"
|
||||||
RR_PARTY_NAME="${stripped#*:}"
|
RR_PARTY_NAME="${stripped#*:}"
|
||||||
rec=$(roster_record_path "$RR_HOST_USER" "$RR_PARTY_NAME")
|
rec="${sock%/*}/roster"
|
||||||
roster_read "$rec" 2>/dev/null || true
|
roster_read "$rec" 2>/dev/null || true
|
||||||
elif [ -n "$partyname" ]; then
|
elif [ -n "$partyname" ]; then
|
||||||
find_party_by_name "$partyname" || exit 1
|
find_party_by_name "$partyname" || exit 1
|
||||||
|
|
@ -1740,12 +1740,14 @@ EOF
|
||||||
host_sess=''
|
host_sess=''
|
||||||
if [ -n "${TMUX:-}" ]; then
|
if [ -n "${TMUX:-}" ]; then
|
||||||
tmux_sock="${TMUX%%,*}"
|
tmux_sock="${TMUX%%,*}"
|
||||||
for rec in $(roster_list); do
|
# Direct read rather than a roster_list walk: roster_read already
|
||||||
roster_read "$rec" || continue
|
# validates the dir basename/ownership and returns 1 for a
|
||||||
[ "$(party_conn_state "$RR_SOCKET")" != dead ] || continue
|
# non-party path, so a personal tmux socket simply falls through
|
||||||
[ "$RR_SOCKET" = "$tmux_sock" ] || continue
|
# to the fallback loop below.
|
||||||
sock="$RR_SOCKET"; host_sess="$RR_PARTY_NAME"; break
|
if roster_read "${tmux_sock%/sock}/roster" \
|
||||||
done
|
&& [ "$(party_conn_state "$RR_SOCKET")" != dead ]; then
|
||||||
|
sock="$RR_SOCKET"; host_sess="$RR_PARTY_NAME"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
if [ -z "$sock" ]; then
|
if [ -z "$sock" ]; then
|
||||||
for rec in $(roster_list); do
|
for rec in $(roster_list); do
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue