v1.8.2: session management hardening
- Fix infinite reconnect loop in terminal (_send_to_shell guard) - Safe language switch: disconnect + reconnect instead of object transplant - Improved SFTP reconnect flow with proper validation - Add log.debug to all silent exception handlers in ssh_client Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -450,16 +450,25 @@ class FilesTab(ctk.CTkFrame):
|
||||
return items
|
||||
|
||||
def _do():
|
||||
try:
|
||||
if not self._sftp.connected:
|
||||
# Ensure connection is alive, reconnect if needed
|
||||
if not self._sftp.connected:
|
||||
try:
|
||||
self._sftp.reconnect()
|
||||
except Exception as e:
|
||||
self.after(0, lambda: self._on_sftp_error(str(e)))
|
||||
return
|
||||
if not self._sftp.connected:
|
||||
self.after(0, lambda: self._on_sftp_error("Reconnect failed"))
|
||||
return
|
||||
|
||||
try:
|
||||
items = _list_remote()
|
||||
self.after(0, lambda: self._populate_remote(items))
|
||||
except PermissionError as e:
|
||||
hint = f"\n{t('try_sudo_hint')}" if not self._sftp.sudo_mode else ""
|
||||
self.after(0, lambda: self._on_sftp_error(str(e) + hint))
|
||||
except Exception:
|
||||
# Connection likely dead — try reconnect once
|
||||
# Operation failed — one reconnect attempt
|
||||
try:
|
||||
self._sftp.reconnect()
|
||||
items = _list_remote()
|
||||
|
||||
@@ -142,9 +142,8 @@ class TerminalTab(ctk.CTkFrame):
|
||||
session = self._session # local ref for thread safety
|
||||
if session and session.connected:
|
||||
session.send(data)
|
||||
elif self._current_alias and not self._intentional_disconnect:
|
||||
# Session dead — trigger reconnect
|
||||
self._reconnect_count = 0
|
||||
elif self._current_alias and not self._intentional_disconnect and self._reconnect_count == 0:
|
||||
# Session dead, no reconnect in progress — trigger one attempt
|
||||
self._on_disconnected()
|
||||
|
||||
def _on_resize(self, cols: int, rows: int):
|
||||
|
||||
Reference in New Issue
Block a user