From f210bad620b3137b2c87bc0ba4f81e7baf71be08 Mon Sep 17 00:00:00 2001 From: Luke Murphy Date: Tue, 13 Oct 2020 13:13:51 +0200 Subject: [PATCH] When send runs through, also remove --- dropship/dropship.py | 2 +- dropship/wormhole.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/dropship/dropship.py b/dropship/dropship.py index 736b840..9740b8f 100644 --- a/dropship/dropship.py +++ b/dropship/dropship.py @@ -143,7 +143,7 @@ class DropShip: async def send(self, fpath): self._send_spinner_on() - code, scope = await self.nursery.start(wormhole_send, fpath) + code, scope = await self.nursery.start(wormhole_send, fpath, self) self._create_pending_transfer(fpath, code, scope) self.clipboard.set_text(code, -1) self._send_spinner_off(code) diff --git a/dropship/wormhole.py b/dropship/wormhole.py index f0018ea..732d866 100644 --- a/dropship/wormhole.py +++ b/dropship/wormhole.py @@ -5,7 +5,7 @@ from trio import TASK_STATUS_IGNORED, CancelScope, open_process, run_process from dropship import log -async def wormhole_send(fpath, task_status=TASK_STATUS_IGNORED): +async def wormhole_send(fpath, parent, task_status=TASK_STATUS_IGNORED): """Run `wormhole send` on a local file path.""" with CancelScope() as scope: command = ["wormhole", "send", fpath] @@ -21,6 +21,8 @@ async def wormhole_send(fpath, task_status=TASK_STATUS_IGNORED): process.terminate() log.info(f"wormhole_send: succesfully terminated process ({code})") + parent._remove_pending_transfer(code) + async def wormhole_recv(code, parent, task_status=TASK_STATUS_IGNORED): """Run `wormhole receive` on a pending transfer code."""