When send runs through, also remove

This commit is contained in:
Luke Murphy 2020-10-13 13:13:51 +02:00
parent 724f665753
commit f210bad620
No known key found for this signature in database
GPG Key ID: 5E2EF5A63E3718CC
2 changed files with 4 additions and 2 deletions

View File

@ -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)

View File

@ -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."""