From 98a5ec45bb4085346a3ce7980c036e92964555f4 Mon Sep 17 00:00:00 2001 From: saphid <4596216+saphid@users.noreply.github.com> Date: Mon, 28 Sep 2026 21:56:00 +1000 Subject: [PATCH] Bundled KDE Connect: tidying up can't leave the pad stuck starting discard() swallows OSError as well as Failure, so a launch that fails and can't remove its copy still reports the error and can be started again. Co-Authored-By: Claude Opus 5.5 (1M context) --- tests/test_input.py | 16 ++++++++++++++++ ui/server.py | 4 ++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/tests/test_input.py b/tests/test_input.py index a214a8b..a5e803d 100644 --- a/tests/test_input.py +++ b/tests/test_input.py @@ -363,6 +363,22 @@ class Bundled(unittest.TestCase): self.server.ssh, self.server.LOCAL = old self.assertEqual(calls, ["rm -rf .local/share/frame-control/kdeconnect/incoming/ab12"]) + def test_a_launch_error_leaves_it_ready_to_try_again(self): + # Popen fails (say, out of file handles) and so does removing the copy: the + # page gets the error and the next start launches. + agent, launches, procs = self.lifecycle([]) + agent.deliver = lambda report, force=False: "~/.local/share/frame-control/kdeconnect/incoming/z" + old_popen, old_ssh = self.server.subprocess.Popen, self.server.ssh + self.server.subprocess.Popen = self.server.ssh = lambda *a, **k: (_ for _ in ()).throw(OSError(24, "Too many open files")) + try: + agent.start() + self.wait_for(lambda: agent.status.get("state") == "error") + finally: + self.server.subprocess.Popen, self.server.ssh = old_popen, old_ssh + self.assertIsNone(agent.launching) + agent.start() + self.wait_for(lambda: agent.status == {"state": "ready"}) + def test_copies_go_to_a_folder_of_their_own(self): first, _, _ = self.deliver(frame_has=False) second, _, _ = self.deliver(frame_has=False) diff --git a/ui/server.py b/ui/server.py index 587a355..b825c32 100755 --- a/ui/server.py +++ b/ui/server.py @@ -659,8 +659,8 @@ class InputAgent: if folder.startswith(f"{KDECONNECT_HOME}/incoming/") and not LOCAL: try: ssh(f"rm -rf {folder}", timeout=20) - except Failure: - pass + except (Failure, OSError): + pass # never let tidying up get in the way of reporting and retrying def start(self): with self.lock: