From a26dc42d886c52e707b2a63861448684941e54c7 Mon Sep 17 00:00:00 2001 From: Leo Vasanko Date: Wed, 1 Nov 2023 14:12:06 +0000 Subject: [PATCH] Fix control message decoding. --- cista/api.py | 4 ++-- cista/protocol.py | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/cista/api.py b/cista/api.py index 39a4a18..279fb1e 100644 --- a/cista/api.py +++ b/cista/api.py @@ -6,7 +6,7 @@ from sanic import Blueprint from cista import watching from cista.fileio import FileServer -from cista.protocol import ControlBase, FileRange, StatusMsg +from cista.protocol import ControlTypes, FileRange, StatusMsg from cista.util.apphelpers import asend, websocket_wrapper bp = Blueprint("api", url_prefix="/api") @@ -76,7 +76,7 @@ async def download(req, ws): @bp.websocket("control") @websocket_wrapper async def control(req, ws): - cmd = msgspec.json.decode(await ws.recv(), type=ControlBase) + cmd = msgspec.json.decode(await ws.recv(), type=ControlTypes) await asyncio.to_thread(cmd) await asend(ws, StatusMsg(status="ack", req=cmd)) diff --git a/cista/protocol.py b/cista/protocol.py index 9ab259b..4a5cf7c 100755 --- a/cista/protocol.py +++ b/cista/protocol.py @@ -78,6 +78,9 @@ class Cp(ControlBase): ) +ControlTypes = MkDir | Rename | Rm | Mv | Cp + + ## File uploads and downloads